Module: Clamp::Command::RunWithCompletion

Included in:
Clamp::Command
Defined in:
lib/clamp/completion.rb

Overview

Adds –shell-completions option and handles the Wanted exception.

Instance Method Summary collapse

Instance Method Details

#run(invocation_path = File.basename($PROGRAM_NAME), arguments = ARGV, context = {}) ⇒ Object



124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/clamp/completion.rb', line 124

def run(invocation_path = File.basename($PROGRAM_NAME), arguments = ARGV, context = {})
  context[:root_command_class] ||= self
  super
rescue Clamp::Completion::Wanted => e
  shell_name = File.basename(e.shell).to_sym
  begin
    puts generate_completion(shell_name, invocation_path)
  rescue ArgumentError => ex
    $stderr.puts "ERROR: #{ex.message}"
    exit(1)
  end
end