class HammerCLI::ShellCommand
Constants
- DEFAULT_HISTORY_FILE
Public Instance Methods
execute()
click to toggle source
# File lib/hammer_cli/shell.rb, line 82 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 history = ShellHistory.new(Settings.get(:ui, :history_file) || DEFAULT_HISTORY_FILE) begin print_welcome_message while line = Readline.readline(prompt) history.push(line) line = HammerCLI::CompleterLine.new(line) ShellMainCommand.run('hammer', line, context) unless line.empty? end rescue Interrupt; end puts system('stty', stty_save) # Restore HammerCLI::EX_OK end
Private Instance Methods
common_prefix(results)
click to toggle source
# File lib/hammer_cli/shell.rb, line 120 def common_prefix(results) results.delete_if{ |r| !r[0].start_with?(results[0][0][0]) }.length == results.length end
complete_proc()
click to toggle source
# File lib/hammer_cli/shell.rb, line 124 def complete_proc completer = Completer.new(ShellMainCommand) Proc.new do |last_word| completer.complete(Readline.line_buffer) end end
print_welcome_message()
click to toggle source
# File lib/hammer_cli/shell.rb, line 115 def print_welcome_message print_message(_("Welcome to the hammer interactive shell.")) print_message(_("Type 'help' for usage information.")) end
prompt()
click to toggle source
# File lib/hammer_cli/shell.rb, line 111 def prompt 'hammer> ' end