Sha256: 6db28f2876f1e9c3739fa06f4afc5480c79e74b1dc9cf6e7839220b1a0888a97
Contents?: true
Size: 1.17 KB
Versions: 1
Compression:
Stored size: 1.17 KB
Contents
module Quickl module Command::Delegate module InstanceMethods # Run the command by delegation def _run(argv = []) # My own options my_argv = [] while argv.first =~ /^--/ my_argv << argv.shift end parse_options(my_argv) # Run the subcommand now if cmd = argv.shift has_command!(cmd).run(argv) else raise Quickl::Help.new(cmd.nil? ? 0 : -1) end end end module ClassMethods def summarized_subcommands doc = subcommands.collect{|cmd| [cmd.command_name, cmd.overview] } max = doc.inject(0){|memo,pair| l = pair.first.length memo > l ? memo : l } doc.collect{|pair| " %-#{max}s %s" % pair }.join("\n") end end end # module Command::Delegate # # Create a delegate command # def self.Delegate(*args) command_builder do |b| b.document *args b.class_module Command::Delegate::ClassMethods b.instance_module Command::Delegate::InstanceMethods end Command end end # module Quickl
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
quickl-0.1.1 | lib/quickl/command/delegate.rb |