Class: Vanagon::CLI::Inspect
- Inherits:
-
Vanagon::CLI
- Object
- Vanagon::CLI
- Vanagon::CLI::Inspect
- Defined in:
- lib/vanagon/cli/inspect.rb
Constant Summary collapse
- DOCUMENTATION =
<<~DOCOPT.freeze Usage: inspect [options] <project-name> <platforms> Options: -h, --help Display help -c, --configdir DIRECTORY Configuration directory [default: #{Dir.pwd}/configs] -e, --engine ENGINE Custom engine to use [base, local, docker, pooler] [default: pooler] -p, --preserve [RULE] Rule for VM preservation: never, on-failure, always [Default: on-failure] -w, --workdir DIRECTORY Working directory on the local host -v, --verbose Only here for backwards compatibility. Does nothing. DOCOPT
Instance Method Summary collapse
- #options_translate(docopt_options) ⇒ Object
- #options_validate(options) ⇒ Object
- #parse(argv) ⇒ Object
- #run(options) ⇒ Object
Instance Method Details
#options_translate(docopt_options) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/vanagon/cli/inspect.rb', line 40 def () translations = { '--verbose' => :verbose, '--workdir' => :workdir, '--configdir' => :configdir, '--engine' => :engine, '--preserve' => :preserve, '<project-name>' => :project_name, '<platforms>' => :platforms } return .map { |k, v| [translations[k], v] }.to_h end |
#options_validate(options) ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/vanagon/cli/inspect.rb', line 53 def () # Handle --preserve option checking valid_preserves = %w[always never on-failure] unless valid_preserves.include? [:preserve] raise InvalidArgument, "--preserve option can only be one of: " + valid_preserves.join(', ') end [:preserve] = [:preserve].to_sym return end |
#parse(argv) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/vanagon/cli/inspect.rb', line 22 def parse(argv) Docopt.docopt(DOCUMENTATION, { argv: argv }) rescue Docopt::Exit => e puts e. exit 1 end |
#run(options) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/vanagon/cli/inspect.rb', line 29 def run() platforms = [:platforms].split(',') project = [:project_name] platforms.each do |platform| driver = Vanagon::Driver.new(platform, project, ) components = driver.project.components.map(&:to_hash) $stdout.puts JSON.pretty_generate(components) end end |