Class: Sunniesnow::Charter::CLI::Subcommand

Inherits:
Object
  • Object
show all
Defined in:
lib/sscharter/cli.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, option_parser, &block) ⇒ Subcommand

Returns a new instance of Subcommand.



37
38
39
40
41
42
# File 'lib/sscharter/cli.rb', line 37

def initialize name, option_parser, &block
	@name = name
	@option_parser = option_parser
	@block = block
	CLI.commands[name] = self
end

Instance Method Details

#runObject



44
45
46
47
48
# File 'lib/sscharter/cli.rb', line 44

def run
	options = {}
	@option_parser.parse! into: options
	@block.(*ARGV, **options)
end