Sha256: 977539603010d10433f37ec051f3feac64b3f8d19738805804b6c37a0020a646
Contents?: true
Size: 1.12 KB
Versions: 3
Compression:
Stored size: 1.12 KB
Contents
require 'thor' require 'yao/cli/formatter' module Yao::Cli class Base < Thor class_option :format, :type => :string, :aliases => :f, :enum => Yao::Cli::Formatter.formats, :desc => "Output format (default: json)" private def pretty_output(obj) format = options[:format] || "json" puts Yao::Cli::Formatter.get(format).dump(obj) end def is_uuid?(str) /^[\da-f]{32}$/ === str or /^[\da-f]{8}-([\da-f]{4}-){3}[\da-f]{12}$/ === str end def generate_params command = caller.first.split(' ')[1].delete('`').delete("'") command_options = self.class.commands[command].options.map do |opt| opt.first.to_s end command_options.map do |name| if opt = options[name] [name, opt] end end.compact.to_h end class << self def banner(command, namespace = nil, subcommand = false) if namespace.nil? && !subcommand # yao lbaas lb help <command> のときにUsageがおかしくなるので対処 super(command, false, true) else super end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
yao-cli-0.2.2 | lib/yao/cli/base.rb |
yao-cli-0.2.1 | lib/yao/cli/base.rb |
yao-cli-0.2.0 | lib/yao/cli/base.rb |