@@ -4,14 +4,17 @@ class Completions < Base
4
4
summary 'Install bash completions for bashly itself'
5
5
help 'Display the bash completions script or install it directly to your bash completions directory'
6
6
7
- usage 'bashly completions [--install]'
7
+ usage 'bashly completions [--install --uninstall ]'
8
8
usage 'bashly completions (-h|--help)'
9
9
10
10
option '-i --install' , 'Install the completions script to your bash completions directory'
11
+ option '-u --uninstall' , 'Uninstall the completions script from your bash completions directory'
11
12
12
13
def run
13
14
if args [ '--install' ]
14
15
install_completions
16
+ elsif args [ '--uninstall' ]
17
+ uninstall_completions
15
18
else
16
19
puts script
17
20
end
@@ -25,14 +28,22 @@ def installer
25
28
26
29
def install_completions
27
30
success = installer . install force : true
28
- raise Error , "Failed running command:\n nb`#{ installer . command_string } `" unless success
31
+ raise Error , "Failed running command:\n nb`#{ installer . install_command_string } `" unless success
29
32
30
- say 'Completions installed. '
33
+ say 'Completions installed'
31
34
say "Source: m`#{ installer . script_path } `"
32
35
say "Target: m`#{ installer . target_path } `"
33
36
say 'Restart your session for the changes to take effect'
34
37
end
35
38
39
+ def uninstall_completions
40
+ success = installer . uninstall
41
+ raise Error , "Failed running command:\n nb`#{ installer . uninstall_command_string } `" unless success
42
+
43
+ say 'Completions uninstalled'
44
+ say 'Restart your session for the changes to take effect'
45
+ end
46
+
36
47
def script_path
37
48
@script_path ||= asset ( 'completions/bashly-completions.bash' )
38
49
end
0 commit comments