Class: HammerCLI::ShellCommand

Inherits:
AbstractCommand show all
Defined in:
lib/hammer_cli/shell.rb

Instance Method Summary collapse

Methods inherited from AbstractCommand

#adapter, #exception_handler, inherited_output_definition, #initialize, output, #output, output_definition, #output_definition, #parent_command, #parse, remove_subcommand, #run, subcommand, subcommand!, validate_options, #validate_options

Constructor Details

This class inherits a constructor from HammerCLI::AbstractCommand

Instance Method Details

#executeObject



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/hammer_cli/shell.rb', line 92

def execute
  ShellMainCommand.load_commands(HammerCLI::MainCommand)

  Readline.completion_append_character = ''
  Readline.completer_word_break_characters = ' '
  Readline.completion_proc = complete_proc

  stty_save = `stty -g`.chomp

  begin
    print_welcome_message
    while line = Readline.readline(prompt, true)
      ShellMainCommand.run('', line.split, context) unless line.start_with? 'shell' or line.strip.empty?
    end
  rescue Interrupt => e
    puts
    system('stty', stty_save) # Restore
    exit
  end
end