Skip to content
This repository was archived by the owner on Oct 22, 2020. It is now read-only.

Commit 9d657de

Browse files
committed
Add setg and unsetg alises
Closes #48
1 parent 19be00e commit 9d657de

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

lib/cli/console.rb

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ class Console
2323
include Cli::Output
2424

2525
def commands_without_output
26-
%w(back)
26+
%w[back]
2727
end
2828

2929
def permitted_commands
30-
%w(use back set show quit run unset check info gset gunset search clear
31-
reload help)
30+
%w[
31+
use back set show quit run unset check info
32+
gset setg gunset unsetg search clear reload help
33+
]
3234
end
3335

3436
def initialize
@@ -112,8 +114,20 @@ def on_event_emitted(event)
112114
end
113115
end
114116

117+
def normalise_alised_commands(command)
118+
if command == 'exit'
119+
'quit'
120+
elsif command == 'setg'
121+
'gset'
122+
elsif command == 'unsetg'
123+
'gunset'
124+
else
125+
command
126+
end
127+
end
128+
115129
def execute_user_command(command, args)
116-
command = 'quit' if command == 'exit'
130+
command = normalise_alised_commands(command)
117131
if can_handle? command
118132
puts unless commands_without_output.include? command
119133
send(command, *args) if correct_number_of_args?(command, args)

0 commit comments

Comments
 (0)