Sha256: e70dd01b2341aa6e398ffecc1011971740ecea903506cf7b8d2a93b769acf956
Contents?: true
Size: 750 Bytes
Versions: 2
Compression:
Stored size: 750 Bytes
Contents
module Clamp class Subcommand < Struct.new(:name, :description, :subcommand_class) def help [name, description] end module Declaration def recognised_subcommands @recognised_subcommands ||= [] end def subcommand(name, description, subcommand_class = self, &block) if block # generate a anonymous sub-class subcommand_class = Class.new(subcommand_class, &block) end recognised_subcommands << Subcommand.new(name, description, subcommand_class) end def has_subcommands? !recognised_subcommands.empty? end def find_subcommand(name) recognised_subcommands.find { |sc| sc.name == name } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
clamp-0.1.0 | lib/clamp/subcommand/declaration.rb |
clamp-0.0.9 | lib/clamp/subcommand/declaration.rb |