Class: Moonshot::Command

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

Overview

A Command that is automatically registered with the Moonshot::CommandLine

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.inherited(base) ⇒ Object



11
12
13
14
# File 'lib/moonshot/command.rb', line 11

def self.inherited(base)
  Moonshot::CommandLine.register(base)
  base.extend(ClassMethods)
end

Instance Method Details

#parserObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/moonshot/command.rb', line 16

def parser
  @use_interactive_logger = true

  OptionParser.new do |o|
    o.banner = "Usage: moonshot #{self.class.usage}"

    o.on('-v', '--[no-]verbose', 'Show debug logging') do |v|
      Moonshot.config.interactive_logger = InteractiveLogger.new(debug: true) if v
    end

    o.on('-nNAME', '--environment=NAME', 'Which environment to operate on.') do |v|
      Moonshot.config.environment_name = v
    end

    o.on('--[no-]interactive-logger', TrueClass, 'Enable or disable fancy logging') do |v|
      @use_interactive_logger = v
    end

    o.on('--[no-]show-all-events', FalseClass, 'Show all stack events during update') do |v|
      Moonshot.config.show_all_stack_events = v
    end

    o.on('-pPARENT_STACK', '--parent=PARENT_STACK',
         'Parent stack to import parameters from') do |v|
      Moonshot.config.parent_stacks = [v]
    end
  end
end