Sha256: e582c2ccec4ed2de8d99255f7e4de32ba32d5f15aa5b8018667cab387b482117
Contents?: true
Size: 1.36 KB
Versions: 16
Compression:
Stored size: 1.36 KB
Contents
#!/usr/bin/env ruby require 'bogo-cli' require 'sfn' if(defined?(Bundler)) begin Bundler.require(:sfn) rescue Bundler::GemfileNotFound # ignore load error end end Bogo::Cli::Setup.define do on :v, :version, 'Print version ' do puts "sfn - SparkleFormation CLI - [Version: #{Sfn::VERSION}]" exit end Sfn::Config.constants.map do |konst| const = Sfn::Config.const_get(konst) if(const.is_a?(Class) && const.ancestors.include?(Bogo::Config)) const end end.compact.sort_by(&:to_s).each do |klass| klass_name = klass.name.split('::').last.downcase command klass_name do if(klass.const_defined?(:DESCRIPTION)) description klass.const_get(:DESCRIPTION) end Sfn::Config.options_for(klass).each do |name, info| on_name = info[:boolean] ? info[:long] : "#{info[:long]}=" opts = Hash.new.tap do |o| o[:default] = info[:default] if info.has_key?(:default) if(info[:multiple]) o[:as] = Array o[:delimiter] = nil end end if(info[:short]) on info[:short], on_name, info[:description], opts else on on_name, info[:description], opts end end run do |opts, args| Bogo::Utility.constantize(klass.to_s.sub('Config', 'Command')).new(opts, args).execute! end end end end
Version data entries
16 entries across 16 versions & 1 rubygems