Class: AM::CLI
Constant Summary
MessageControl::ERROR_MESSAGE, MessageControl::NOTICE_MESSAGE, MessageControl::WARNING_MESSAGE
Instance Method Summary
collapse
Methods included from Validate
#uniq?, #valid?
#after_sepalate, #before_sepalate, #error, #notice, #print_message, #warning
Constructor Details
#initialize(*args) ⇒ CLI
17
18
19
20
21
22
|
# File 'lib/am/cli.rb', line 17
def initialize(*args)
super
@config = Config.new
@ui = Ui.new
@tail = Tail.new(@config)
end
|
Instance Method Details
#add ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/am/cli.rb', line 34
def add
commands = @tail.get_last_command
error(:not_exists_history_record) if commands.nil?
@ui.print_last_commands(commands)
new_alias = @ui.add_command_with_number(commands)
unless Hash.try_convert(new_alias)
add
else
if uniq?(new_alias)
@config.add_config(new_alias)
end
end
end
|
#del ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/am/cli.rb', line 52
def del
unless @config.al.empty?
@ui.print_current_config(@config)
delete_alias = @ui.delete_command_with_number(@config)
unless delete_alias.nil?
@config.al.delete(delete_alias)
@config.delete_config(delete_alias)
else
del
end
else
notice(:config_empty)
end
end
|
#show ⇒ Object
25
26
27
28
29
30
31
|
# File 'lib/am/cli.rb', line 25
def show
if @config.al.empty?
notice(:config_empty)
else
@ui.print_current_config(@config)
end
end
|