File tree Expand file tree Collapse file tree 4 files changed +74
-68
lines changed Expand file tree Collapse file tree 4 files changed +74
-68
lines changed Original file line number Diff line number Diff line change 1
1
# shellcheck shell=bash
2
2
3
- do_set () {
4
- local category=" $1 "
5
- local program=" $2 "
6
- local gui=" $3 "
7
-
8
- # Get category
9
- if ! helper_get_category " $category " " $gui " ; then
10
- log.die " $gui " " Could not get category"
11
- fi
12
- category=" $REPLY "
13
-
14
- # Get program
15
- if ! helper_get_program " $category " " $program " " $gui " ; then
16
- log.die " $gui " " Could not get program"
17
- fi
18
- program=" $REPLY "
19
-
20
- # -------------------------- set ------------------------- #
21
- # Source category pre
22
- if [ -f " $db_dir /$category /set-pre.sh" ]; then
23
- if ! sh -e " $db_dir /$category /set-pre.sh" " $db_dir /$category " " $program " ; then
24
- return 1
25
- fi
26
- fi
27
-
28
- # Source program pre
29
- if [ -f " $db_dir /$category /$program /set-pre.sh" ]; then
30
- if ! sh -e " $db_dir /$category /$program /set-pre.sh" " $db_dir /$category " " $program " ; then
31
- return 1
32
- fi
33
- fi
34
-
35
- # Actually set
36
- printf " %s" " $program " > | " $db_dir /$category /_.current"
37
-
38
- # Source program post
39
- if [ -f " $db_dir /$category /$program /set-post.sh" ]; then
40
- if ! sh -e " $db_dir /$category /$program /set-post.sh" " $db_dir /$category " " $program " ; then
41
- return 1
42
- fi
43
- fi
44
-
45
- # Source category post
46
- if [ -f " $db_dir /$category /set-post.sh" ]; then
47
- if ! sh -e " $db_dir /$category /set-post.sh" " $db_dir /$category " " $program " ; then
48
- return 1
49
- fi
50
- fi
51
-
52
- log.info " Category '$category ' defaults to '$program '"
53
- }
54
-
55
- do_launch () {
3
+ choose-launch () {
56
4
local category=" $1 "
57
5
local gui=" $2 "
58
6
@@ -113,15 +61,3 @@ do_launch() {
113
61
fi
114
62
fi
115
63
}
116
-
117
- do_print () {
118
- local category=" $1 "
119
-
120
- program=" $( < " $db_dir /$category /_.current" ) "
121
-
122
- # ensure variable (we already use 'ensure_has_dot_current' in
123
- # helper_get_category_filter; this is another safeguard)
124
- if [ -z " $program " ]; then
125
- log.die " $gui " " Program for '$category ' is not set. Please set with 'choose set'"
126
- fi
127
- }
Original file line number Diff line number Diff line change
1
+ # shellcheck shell=bash
2
+
3
+ choose-print () {
4
+ local category=" $1 "
5
+
6
+ program=" $( < " $db_dir /$category /_.current" ) "
7
+
8
+ # ensure variable (we already use 'ensure_has_dot_current' in
9
+ # helper_get_category_filter; this is another safeguard)
10
+ if [ -z " $program " ]; then
11
+ log.die " $gui " " Program for '$category ' is not set. Please set with 'choose set'"
12
+ fi
13
+ }
Original file line number Diff line number Diff line change
1
+ # shellcheck shell=bash
2
+
3
+ choose-set () {
4
+ local category=" $1 "
5
+ local program=" $2 "
6
+ local gui=" $3 "
7
+
8
+ # Get category
9
+ if ! helper_get_category " $category " " $gui " ; then
10
+ log.die " $gui " " Could not get category"
11
+ fi
12
+ category=" $REPLY "
13
+
14
+ # Get program
15
+ if ! helper_get_program " $category " " $program " " $gui " ; then
16
+ log.die " $gui " " Could not get program"
17
+ fi
18
+ program=" $REPLY "
19
+
20
+ # -------------------------- set ------------------------- #
21
+ # Source category pre
22
+ if [ -f " $db_dir /$category /set-pre.sh" ]; then
23
+ if ! sh -e " $db_dir /$category /set-pre.sh" " $db_dir /$category " " $program " ; then
24
+ return 1
25
+ fi
26
+ fi
27
+
28
+ # Source program pre
29
+ if [ -f " $db_dir /$category /$program /set-pre.sh" ]; then
30
+ if ! sh -e " $db_dir /$category /$program /set-pre.sh" " $db_dir /$category " " $program " ; then
31
+ return 1
32
+ fi
33
+ fi
34
+
35
+ # Actually set
36
+ printf " %s" " $program " > | " $db_dir /$category /_.current"
37
+
38
+ # Source program post
39
+ if [ -f " $db_dir /$category /$program /set-post.sh" ]; then
40
+ if ! sh -e " $db_dir /$category /$program /set-post.sh" " $db_dir /$category " " $program " ; then
41
+ return 1
42
+ fi
43
+ fi
44
+
45
+ # Source category post
46
+ if [ -f " $db_dir /$category /set-post.sh" ]; then
47
+ if ! sh -e " $db_dir /$category /set-post.sh" " $db_dir /$category " " $program " ; then
48
+ return 1
49
+ fi
50
+ fi
51
+
52
+ log.info " Category '$category ' defaults to '$program '"
53
+ }
54
+
Original file line number Diff line number Diff line change @@ -30,17 +30,20 @@ main.choose() {
30
30
local category=" ${argsCommands[1]} "
31
31
local program=" ${argsCommands[2]} "
32
32
33
- do_set " $category " " $program " " $gui "
33
+ source " $BASALT_PACKAGE_DIR /pkg/commands/choose-set.sh"
34
+ choose-set " $category " " $program " " $gui "
34
35
;;
35
36
launch)
36
37
local category=" ${argsCommands[1]} "
37
38
38
- do_launch " $category " " $gui "
39
+ source " $BASALT_PACKAGE_DIR /pkg/commands/choose-launch.sh"
40
+ choose-launch " $category " " $gui "
39
41
;;
40
42
print)
41
43
local category=" ${argsCommands[1]} "
42
44
43
- do_print " $category " " $gui "
45
+ source " $BASALT_PACKAGE_DIR /pkg/commands/choose-print.sh"
46
+ choose-print " $category " " $gui "
44
47
;;
45
48
* )
46
49
log.die " Subcommand '${argsCommands[0]} ' not found"
You can’t perform that action at this time.
0 commit comments