Class: AM::CLI
- Inherits:
-
Thor
- Object
- Thor
- AM::CLI
- Includes:
- MessageControl, Validate
- Defined in:
- lib/am/cli.rb
Constant Summary
Constants included from MessageControl
MessageControl::ERROR_MESSAGE, MessageControl::NOTICE_MESSAGE, MessageControl::WARNING_MESSAGE
Instance Method Summary collapse
- #add ⇒ Object
- #del ⇒ Object
-
#initialize(*args) ⇒ CLI
constructor
A new instance of CLI.
- #show ⇒ Object
Methods included from Validate
Methods included from MessageControl
#after_sepalate, #before_sepalate, #error, #notice, #print_message, #warning
Constructor Details
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 |