File tree Expand file tree Collapse file tree 6 files changed +102
-6
lines changed Expand file tree Collapse file tree 6 files changed +102
-6
lines changed Original file line number Diff line number Diff line change 1
1
# shellcheck shell=bash
2
2
3
3
do-add () {
4
- local with_ssh=' no'
4
+ local with_ssh=' no' # TODO: refactor flag_
5
+ local flag_all=' no'
5
6
6
7
local -a pkgs=()
7
8
for arg; do
8
9
case " $arg " in
9
10
--ssh)
10
11
with_ssh=' yes'
11
12
;;
13
+ --all)
14
+ flag_all=' yes'
15
+ ;;
12
16
* )
13
17
pkgs+=(" $arg " )
14
18
;;
15
19
esac
16
20
done
17
21
22
+ if [ " $flag_all " = yes ]; then
23
+ local bpm_toml_file=" $BPM_ROOT /bpm.toml"
24
+
25
+ if (( ${# pkgs[@]} > 0 )) ; then
26
+ die " You must not supply any packages when using '--all'"
27
+ fi
28
+
29
+ if util.get_toml_array " $bpm_toml_file " ' dependencies' ; then
30
+ log.info " Adding all dependencies"
31
+
32
+ for pkg in " ${REPLIES[@]} " ; do
33
+ do-add " $pkg "
34
+ done
35
+ else
36
+ log.warn " No dependencies specified in 'dependencies' key"
37
+ fi
38
+
39
+ return
40
+ fi
41
+
18
42
if (( ${# pkgs[@]} == 0 )) ; then
19
43
die " At least one package must be supplied"
20
44
fi
Original file line number Diff line number Diff line change 1
1
# shellcheck shell=bash
2
2
3
3
do-remove () {
4
- if (( $# == 0 )) ; then
4
+ local flag_all=' no'
5
+
6
+ local -a pkgs=()
7
+ for arg; do
8
+ case " $arg " in
9
+ --all)
10
+ flag_all=' yes'
11
+ ;;
12
+ * )
13
+ pkgs+=(" $arg " )
14
+ ;;
15
+ esac
16
+ done
17
+
18
+ if [ " $flag_all " = yes ]; then
19
+ local bpm_toml_file=" $BPM_ROOT /bpm.toml"
20
+
21
+ if (( ${# pkgs[@]} > 0 )) ; then
22
+ die " You must not supply any packages when using '--all'"
23
+ fi
24
+
25
+ if util.get_toml_array " $bpm_toml_file " ' dependencies' ; then
26
+ log.info " Removing all dependencies"
27
+
28
+ for pkg in " ${REPLIES[@]} " ; do
29
+ do-remove " $pkg "
30
+ done
31
+ else
32
+ log.warn " No dependencies specified in 'dependencies' key"
33
+ fi
34
+
35
+ return
36
+ fi
37
+
38
+ if (( ${# pkgs[@]} == 0 )) ; then
5
39
die " You must supply at least one package"
6
40
fi
7
41
8
- for repoSpec; do
42
+ for repoSpec in " ${pkgs[@]} " ; do
9
43
util.extract_data_from_input " $repoSpec "
10
44
local site=" $REPLY2 "
11
45
local package=" $REPLY3 "
Original file line number Diff line number Diff line change @@ -200,7 +200,7 @@ abstract.completions_do_action_fish() {
200
200
case " $action " in
201
201
link)
202
202
if [ -L " $BPM_INSTALL_COMPLETIONS /fish/${file##*/ } " ]; then
203
- log.error " Skipping '$fileName ' since an existing symlink with the same name already exists"
203
+ log.error " Skipping '$fileName ' since an existing symlink with the same name already exists"
204
204
else
205
205
mkdir -p " $BPM_INSTALL_COMPLETIONS /fish"
206
206
ln -sf " $file " " $BPM_INSTALL_COMPLETIONS /fish/${file##*/ } "
Original file line number Diff line number Diff line change @@ -258,10 +258,10 @@ Subcommands:
258
258
init <shell>
259
259
Configure shell environment for Basher
260
260
261
- add [--ssh] [[site/]<package>[@ref]...]
261
+ add [--ssh] [--all] [ [site/]<package>[@ref]...]
262
262
Installs a package from GitHub (or a custom site)
263
263
264
- remove <package...>
264
+ remove [--all] <package...>
265
265
Uninstalls a package
266
266
267
267
link [--no-deps] <directory...>
Original file line number Diff line number Diff line change @@ -204,3 +204,22 @@ load 'util/init.sh'
204
204
assert_success
205
205
assert_line " do-plumbing-clone https://github.com/username/package.git github.com/username/package"
206
206
}
207
+
208
+ @test " --all prints warning when no dependencies are specified in bpm.toml" {
209
+ touch ' bpm.toml'
210
+
211
+ run do-add --all
212
+
213
+ assert_success
214
+ assert_line -p " No dependencies specified in 'dependencies' key"
215
+ refute_line -p " Installing"
216
+ }
217
+
218
+ @test " --all errors when a package is specified as argument" {
219
+ touch ' bpm.toml'
220
+
221
+ run do-add --all pkg
222
+
223
+ assert_failure
224
+ assert_line -p " You must not supply any packages when using '--all'"
225
+ }
Original file line number Diff line number Diff line change @@ -156,3 +156,22 @@ load 'util/init.sh'
156
156
assert [ -d " $BPM_PACKAGES_PATH /$site /$pkg2 " ]
157
157
assert [ -e " $BPM_INSTALL_BIN /exec2" ]
158
158
}
159
+
160
+ @test " --all prints warning when no dependencies are specified in bpm.toml" {
161
+ touch ' bpm.toml'
162
+
163
+ run do-remove --all
164
+
165
+ assert_success
166
+ assert_line -p " No dependencies specified in 'dependencies' key"
167
+ refute_line -p " Installing"
168
+ }
169
+
170
+ @test " --all errors when a package is specified as argument" {
171
+ touch ' bpm.toml'
172
+
173
+ run do-remove --all pkg
174
+
175
+ assert_failure
176
+ assert_line -p " You must not supply any packages when using '--all'"
177
+ }
You can’t perform that action at this time.
0 commit comments