Class: HammerCLI::Subcommand::Definition

Inherits:
Clamp::Subcommand::Definition
  • Object
show all
Defined in:
lib/hammer_cli/subcommand.rb

Direct Known Subclasses

LazyDefinition

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(names, description, subcommand_class, options = {}) ⇒ Definition

Returns a new instance of Definition.



8
9
10
11
12
13
14
15
# File 'lib/hammer_cli/subcommand.rb', line 8

def initialize(names, description, subcommand_class, options = {})
  @names = Array(names)
  @description = description
  @subcommand_class = subcommand_class
  @hidden = options[:hidden]
  @warning = options[:warning]
  super(@names, @description, @subcommand_class)
end

Instance Attribute Details

#warningObject (readonly)

Returns the value of attribute warning.



32
33
34
# File 'lib/hammer_cli/subcommand.rb', line 32

def warning
  @warning
end

Instance Method Details

#helpObject



27
28
29
30
# File 'lib/hammer_cli/subcommand.rb', line 27

def help
  names = HammerCLI.context[:full_help] ? @names.join(", ") : @names.first
  [names, description]
end

#hidden?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/hammer_cli/subcommand.rb', line 17

def hidden?
  @hidden
end

#subcommand_classObject



21
22
23
24
25
# File 'lib/hammer_cli/subcommand.rb', line 21

def subcommand_class
  @warning ||= @subcommand_class.warning
  warn(@warning) if @warning
  @subcommand_class
end