lib/koma/cli.rb in koma-0.5.0 vs lib/koma/cli.rb in koma-0.6.0

- old
+ new

@@ -8,10 +8,14 @@ option :key, type: :string, banner: '<key1,key2,..>', desc: 'inventory keys', aliases: :k + option :yaml, + type: :boolean, + desc: 'stdout YAML', + aliases: :y option :identity_file, type: :string, banner: '<identity_file>', desc: 'identity file', aliases: :i @@ -20,21 +24,33 @@ banner: '<port>', desc: 'port', aliases: :p def ssh(host) backend = Koma::Backend::Ssh.new(host, options) - puts JSON.pretty_generate(backend.gather) + if options[:yaml] + puts YAML.dump(backend.gather) + else + puts JSON.pretty_generate(backend.gather) + end end desc 'exec', 'stdout local host inventory' option :key, type: :string, banner: '<key1,key2,..>', desc: 'inventory keys', aliases: :k + option :yaml, + type: :boolean, + desc: 'stdout YAML', + aliases: :y def exec backend = Koma::Backend::Exec.new(nil, options) - puts JSON.pretty_generate(backend.gather) + if options[:yaml] + puts YAML.dump(backend.gather) + else + puts JSON.pretty_generate(backend.gather) + end end desc 'keys', 'host inventory keys' def keys Specinfra::HostInventory.inventory_keys.each do |key|