Class: Popo::OptParse

Inherits:
Object
  • Object
show all
Includes:
Constants
Defined in:
lib/popo/opt_parse.rb

Constant Summary

Constants included from Constants

Constants::COLOR_GREEN, Constants::COLOR_NONE, Constants::COLOR_RED, Constants::COLOR_YELLOW, Constants::DEFAULT_CONFIG_FILE, Constants::DEFAULT_POPO_TARGET, Constants::POPORC, Constants::POPO_COMMANDS, Constants::POPO_CONFIG, Constants::POPO_DIR_KEY, Constants::POPO_KEY_VALUES, Constants::POPO_WORK_PATH, Constants::POPO_YML_FILE, Constants::POST_INSTALL_NOTE, Constants::REQUIRED_COMMANDS

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOptParse

Returns a new instance of OptParse.



9
10
11
12
13
14
15
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/popo/opt_parse.rb', line 9

def initialize
  @options = {}
  @options[:verbose] = false

  @optparse = OptionParser.new do |options|
    options.banner = "Usage: popo COMMAND [options]"
    options.separator ""
    options.separator "Commands: #{POPO_COMMANDS.join(',')}"
    options.separator ""
    options.separator "options:"

    options.on('-p', '--path PATH', 'Target path') do |path|
      @options[:path] = path
    end

    options.on('-t', '--target TARGET', 'Deployment target') do |target|
      @options[:target] = target
    end

    options.on('-u', '--user USER', 'Specify a username for git') do |user|
      @options[:user] = user
    end

    options.on('-m', '--manifest MANIFEST', 'Specify a manifest repo') do |manifest|
      @options[:manifest] = manifest
    end

    options.on('-l', '--location LOCATION', 'Set the deployment location') do |location|
      @options[:location] = location
    end

    options.on('-r', '--reset', 'WARNING: It will not stash changes') do
      @options[:reset] = true
    end

    options.on('-v', '--verbose', 'Prints more info about what you executed') do
      @options[:verbose] = true
    end

    options.on('-V', '--version', 'Show popo\'s current version') do
      puts Popo::VERSION
      exit
    end

    options.on('-h', '--help', 'Display this screen') do
      puts options
      exit
    end
  end
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/popo/opt_parse.rb', line 7

def options
  @options
end

#optparseObject (readonly)

Returns the value of attribute optparse.



7
8
9
# File 'lib/popo/opt_parse.rb', line 7

def optparse
  @optparse
end