Class: RecordOnChain::Commands::Help
- Inherits:
-
AbstractCommand
- Object
- AbstractCommand
- RecordOnChain::Commands::Help
- Defined in:
- lib/record_on_chain/commands/help.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv = ARGV, cli = Cli.new) ⇒ Help
constructor
A new instance of Help.
- #start ⇒ Object
Methods inherited from AbstractCommand
Constructor Details
#initialize(argv = ARGV, cli = Cli.new) ⇒ Help
Returns a new instance of Help.
17 18 19 |
# File 'lib/record_on_chain/commands/help.rb', line 17 def initialize( argv= ARGV , cli= Cli.new ) super( argv.first , cli ) end |
Class Method Details
.description ⇒ Object
11 12 13 |
# File 'lib/record_on_chain/commands/help.rb', line 11 def self.description return "display usage" end |
.usage ⇒ Object
15 |
# File 'lib/record_on_chain/commands/help.rb', line 15 def self.usage; end |
Instance Method Details
#start ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/record_on_chain/commands/help.rb', line 21 def start command_names = [ "init", "record", "secret", "help" ] # command_name : description descriptions = {} # command_name : usage examples = {} command_names.each do |name| klass = Object.const_get( "RecordOnChain::Commands::#{name.capitalize}" ) description = klass.send( :description ) descriptions[ name ] = description unless description.nil? examples[ name ] = klass.usage unless klass.usage.nil? end @cli.puts_enhance_msg( "== Record on Chain HELP ==" ) @cli.blank_line @cli.puts_underline_msg("description") @cli.puts_hash( descriptions , nil , 1 ) @cli.blank_line @cli.puts_underline_msg("usage") examples.each do | c_name, usage | @cli.out.puts( " [ #{c_name} ]" ) @cli.out.puts( "#{usage}" ) @cli.blank_line end end |