1
1
# shellcheck shell=bash
2
2
3
- # @description Tool names aren't required to be specified on the command line. If one
4
- # isn't specified, then start a TUI selection screen
5
- helper.determine_tool_pair () {
3
+ helper.determine_tool_pair_active () {
6
4
unset -v REPLY; REPLY=
7
5
local input=" $1 "
8
6
9
- local tool_pair=
10
- local plugin_name=
11
- local tool_name=
12
-
13
- if [ -z " $input " ]; then
14
- util.plugin_get_plugins --filter=active --with=name
15
- local -a all_plugins_arr=(" ${REPLY[@]} " )
16
- local -A all_plugins_obj=()
17
- for m in " ${all_plugins_arr[@]} " ; do
18
- all_plugins_obj[" $m " ]=
19
- done ; unset -v m
20
- tty.multiselect ' ' all_plugins_arr all_plugins_obj
21
- plugin_name=" $REPLY "
22
-
23
- util.plugin_get_active_tools_of_plugin " $plugin_name "
24
- local all_tools_arr=(" ${REPLY[@]} " )
25
- local -A all_tools_obj=()
26
- for m in " ${all_tools_arr[@]} " ; do
27
- all_tools_obj[" $m " ]=
28
- done ; unset -v m
29
- tty.multiselect ' ' all_tools_arr all_tools_obj
30
- tool_name=" $REPLY "
31
-
32
- tool_pair=" $plugin_name /$tool_name "
33
- elif [[ " $input " != * /* ]]; then
34
- util.plugin_get_active_tools --with=pair
35
- local tools=(" ${REPLY[@]} " )
36
-
37
- local tool=
38
- for tool in " ${tools[@]} " ; do
39
- if [ " $input " = " ${tool#*/ } " ]; then
40
- plugin_name=${tool%/* }
41
- tool_name=${tool#*/ }
42
-
43
- tool_pair=" $plugin_name /$tool_name "
44
- break
45
- fi
46
- done
47
-
48
- if [ -z " $tool_name " ]; then
49
-
50
- util.plugin_get_active_tools_of_plugin " $input "
51
- local all_tools_arr=(" ${REPLY[@]} " )
52
- local -A all_tools_obj=()
53
- for m in " ${all_tools_arr[@]} " ; do
54
- all_tools_obj[" $m " ]=
55
- done ; unset -v m
56
- tty.multiselect ' ' all_tools_arr all_tools_obj
57
- local _tool_name=" $REPLY "
58
-
59
- plugin_name=$input
60
- tool_name=" $_tool_name "
61
-
62
- tool_pair=" $plugin_name /$tool_name "
63
- fi
64
- else
65
- plugin_name=${input%/* }
66
- tool_name=${input#*/ }
67
-
68
- tool_pair=$input
69
- fi
7
+ util.determine_tool_pair " $input " ' active'
8
+ local tool_pair=$REPLY1
9
+ local plugin_name=$REPLY2
10
+ local tool_name=$REPLY3
70
11
71
12
var.get_tool_file " $plugin_name " " $tool_name "
72
13
local tool_file=" $REPLY "
@@ -80,48 +21,33 @@ helper.determine_tool_pair() {
80
21
util.print_error_die " Could not successfully source plugin '$tool_pair '"
81
22
fi
82
23
83
- REPLY =$tool_pair
84
- REPLY1 =$plugin_name
85
- REPLY2 =$tool_name
24
+ REPLY1 =$tool_pair
25
+ REPLY2 =$plugin_name
26
+ REPLY3 =$tool_name
86
27
}
87
28
88
29
helper.determine_tool_pair_installed () {
89
30
unset -v REPLY; REPLY=
90
- local tool_pair=" $1 "
31
+ local input=" $1 "
32
+
33
+ util.determine_tool_pair " $input " ' installed'
34
+ local tool_pair=$REPLY1
35
+ local plugin_name=$REPLY2
36
+ local tool_name=$REPLY3
91
37
92
38
var.get_dir ' tools' " $tool_pair "
93
39
local install_dir=" $REPLY "
94
40
95
- if [ -z " $tool_pair " ]; then
96
- core.shopt_push -s nullglob
97
- local -a plugin_list=(" $install_dir " /* /)
98
- core.shopt_pop
99
-
100
- if (( ${# plugin_list[@]} == 0 )) ; then
101
- util.print_error_die " Cannot uninstall as no plugins are installed"
102
- fi
103
-
104
- plugin_list=(" ${plugin_list[@]%/ } " )
105
- plugin_list=(" ${plugin_list[@]##*/ } " )
106
-
107
- local -A plugins_table=()
108
- local plugin=
109
- for plugin in " ${plugin_list[@]} " ; do
110
- plugins_table[" $plugin " ]=
111
- done ; unset plugin
112
-
113
- tty.multiselect 0 plugin_list plugins_table
114
- tool_pair=$REPLY
115
- fi
116
-
117
41
if [ ! -d " $install_dir " ]; then
118
42
util.print_error_die " No versions of plugin '$tool_pair ' are installed"
119
43
fi
120
44
121
- REPLY=$tool_pair
45
+ REPLY1=$tool_pair
46
+ REPLY2=$plugin_name
47
+ REPLY3=$tool_name
122
48
}
123
49
124
- helper.determine_tool_version () {
50
+ helper.determine_tool_version_active () {
125
51
unset -v REPLY; REPLY=
126
52
local flag_allow_latest=' no'
127
53
if [ " $1 " = ' --allow-latest' ]; then
0 commit comments