class Vanagon::CLI::Completion
Constants
- DOCUMENTATION
Public Instance Methods
options_translate(docopt_options)
click to toggle source
# File lib/vanagon/cli/completion.rb, line 36 def options_translate(docopt_options) translations = { '--shell' => :shell, } return docopt_options.map { |k, v| [translations[k], v] }.to_h end
parse(argv)
click to toggle source
# File lib/vanagon/cli/completion.rb, line 16 def parse(argv) Docopt.docopt(DOCUMENTATION, { argv: argv }) rescue Docopt::Exit => e VanagonLogger.error e.message exit 1 end
run(options)
click to toggle source
# File lib/vanagon/cli/completion.rb, line 23 def run(options) shell = options[:shell].downcase.strip completion_file = File.expand_path(File.join('..', '..', '..', '..', 'extras', 'completions', "vanagon.#{shell}"), __FILE__) if File.exist?(completion_file) VanagonLogger.warn completion_file exit 0 else VanagonLogger.error "Could not find completion file for '#{shell}': No such file #{completion_file}" exit 1 end end