Sha256: aeb99565ee8a09b66ccacb89156c822828ecc8b22cd736fdfb7cda68e28e0629
Contents?: true
Size: 1.52 KB
Versions: 6
Compression:
Stored size: 1.52 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| command = Bogo::Utility.constantize(klass.to_s.sub("Config", "Command")).new(opts, args) begin command.execute! rescue Bogo::Ui::ConfirmationDeclined command.ui.error "Confirmation declined!" exit 1 end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
sfn-3.1.8 | bin/sfn |
sfn-3.1.6 | bin/sfn |
sfn-3.1.4 | bin/sfn |
sfn-3.1.2 | bin/sfn |
sfn-3.1.0 | bin/sfn |
sfn-3.0.32 | bin/sfn |