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



13
14
15
16
# File 'lib/moonshot/command.rb', line 13

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

Instance Method Details

#parserObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/moonshot/command.rb', line 18

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
  end
end