Class: BunBun::CLI::Command

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



31
32
33
# File 'lib/bunbun/cli/command.rb', line 31

def options
  @options
end

Class Method Details

.argument_countObject



19
20
21
# File 'lib/bunbun/cli/command.rb', line 19

def self.argument_count
  argument_names.length
end

.argument_namesObject



15
16
17
# File 'lib/bunbun/cli/command.rb', line 15

def self.argument_names
  @argument_names ||= instance_method(:call).parameters.select { _1[0] == :req || _1[0] == :opt }.map { _1[1] }
end

.option(name) ⇒ Object



11
12
13
# File 'lib/bunbun/cli/command.rb', line 11

def self.option(name)
  options << name
end

.optionsObject



7
8
9
# File 'lib/bunbun/cli/command.rb', line 7

def self.options
  @options ||= []
end

Instance Method Details

#callObject



33
34
# File 'lib/bunbun/cli/command.rb', line 33

def call
end

#option_parserObject



23
24
25
26
27
28
29
# File 'lib/bunbun/cli/command.rb', line 23

def option_parser
  OptionParser.new do |opts|
    self.class.options.each do |name|
      opts.on("--#{name}=VALUE")
    end
  end
end