bin/onering in onering-client-0.2.1 vs bin/onering in onering-client-0.2.3
- old
+ new
@@ -3,11 +3,11 @@
require 'onering'
require 'hashlib'
require 'rainbow'
require 'pp'
-plugins = Onering::CLI.submodules.collect{|i| i.name.split('::').last.downcase }
+plugins = Onering::CLI::Plugin.registered_plugins.collect{|i| i.name.split('::').last.downcase }
exclude_plugins = %w{devices}
global = Trollop::options do
banner <<-EOS
onering command line client utility - version #{Onering::Client::VERSION}
@@ -23,11 +23,11 @@
opt :url, "The URL of the Onering server to connect to", :short => '-s', :type => :string
opt :path, "The base path to prepend to all requests (default: /api)", :type => :string
opt :source, "Specify the source IP address to use (i.e. which network interface the request should originate from)", :short => '-I', :type => :string
opt :param, "Additional query string parameters to include with the request in the format FIELD=VALUE. Can be specified multiple times.", :short => '-p', :type => :string, :multi => true
- opt :format, "The output format for return values (i.e.: json, yaml, text)", :default => 'text', :short => '-t', :type => :string
+ opt :format, "The output format for return values (i.e.: json, yaml, text)", :short => '-t', :type => :string
opt :sslkey, "Location of the SSL client key to use for authentication", :short => '-c', :type => :string
opt :nosslverify, "Disable verification of the server SSL certificate", :type => :boolean
opt :apikey, "The API token to use for authentication", :short => '-k', :type => :string
opt :quiet, "Suppress standard output", :short => '-q'
opt :separator, "A string used to separate output values of delimited tabular data", :short => '-S', :default => "\t"
@@ -50,10 +50,10 @@
plugin = Onering::CLI.const_get(plugin.capitalize)
plugin.configure(global)
Onering::Logger.debug("Executing plugin #{plugin}\#run()", $0)
rv = plugin.run(ARGV)
- Onering::CLI.output(rv, global[:format])
+ Onering::CLI.output(rv, (global[:format] || plugin.default_format(rv, ARGV) || 'text'))
rescue Onering::API::Errors::Exception => e
Onering::Logger.fatal(e.message, e.class.name.split('::').last) rescue nil
exit 1