Class: Fig::Command::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/fig/command/options.rb,
lib/fig/command/options/parser.rb

Overview

Command-line processing.

Defined Under Namespace

Classes: Parser

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOptions

Returns a new instance of Options.



59
60
61
62
# File 'lib/fig/command/options.rb', line 59

def initialize()
  @home   = ENV['FIG_HOME'] || File.expand_path('~/.fighome')
  @parser = Fig::Command::Options::Parser.new()
end

Instance Attribute Details

#command_extra_argvObject (readonly)

Returns the value of attribute command_extra_argv.



42
43
44
# File 'lib/fig/command/options.rb', line 42

def command_extra_argv
  @command_extra_argv
end

#configObject (readonly)

Returns the value of attribute config.



43
44
45
# File 'lib/fig/command/options.rb', line 43

def config
  @config
end

#descriptorObject (readonly)

Returns the value of attribute descriptor.



44
45
46
# File 'lib/fig/command/options.rb', line 44

def descriptor
  @descriptor
end

#environment_statementsObject (readonly)

Returns the value of attribute environment_statements.



45
46
47
# File 'lib/fig/command/options.rb', line 45

def environment_statements
  @environment_statements
end

#exit_codeObject (readonly)

Returns the value of attribute exit_code.



46
47
48
# File 'lib/fig/command/options.rb', line 46

def exit_code
  @exit_code
end

#figrcObject (readonly)

Returns the value of attribute figrc.



47
48
49
# File 'lib/fig/command/options.rb', line 47

def figrc
  @figrc
end

#homeObject (readonly)

Returns the value of attribute home.



48
49
50
# File 'lib/fig/command/options.rb', line 48

def home
  @home
end

#log_configObject (readonly)

Returns the value of attribute log_config.



49
50
51
# File 'lib/fig/command/options.rb', line 49

def log_config
  @log_config
end

#log_levelObject (readonly)

Returns the value of attribute log_level.



50
51
52
# File 'lib/fig/command/options.rb', line 50

def log_level
  @log_level
end

#package_contents_statementsObject (readonly)

Returns the value of attribute package_contents_statements.



51
52
53
# File 'lib/fig/command/options.rb', line 51

def package_contents_statements
  @package_contents_statements
end

#package_definition_fileObject (readonly)

Returns the value of attribute package_definition_file.



52
53
54
# File 'lib/fig/command/options.rb', line 52

def package_definition_file
  @package_definition_file
end

#parserObject (readonly)

Returns the value of attribute parser.



53
54
55
# File 'lib/fig/command/options.rb', line 53

def parser
  @parser
end

#shell_commandObject (readonly)

Returns the value of attribute shell_command.



54
55
56
# File 'lib/fig/command/options.rb', line 54

def shell_command
  @shell_command
end

#update_lock_responseObject (readonly)

Returns the value of attribute update_lock_response.



55
56
57
# File 'lib/fig/command/options.rb', line 55

def update_lock_response
  @update_lock_response
end

#variable_to_getObject (readonly)

Returns the value of attribute variable_to_get.



56
57
58
# File 'lib/fig/command/options.rb', line 56

def variable_to_get
  @variable_to_get
end

#version_messageObject

Returns the value of attribute version_message.



57
58
59
# File 'lib/fig/command/options.rb', line 57

def version_message
  @version_message
end

Instance Method Details

#actionsObject



93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/fig/command/options.rb', line 93

def actions()
  actions = []

  # Update has got to come first so that the Repository knows what's going
  # on.
  if @update_action
    actions << @update_action
  end
  if @base_action
    actions << @base_action
  end

  return actions
end

#force?Boolean

Returns:

  • (Boolean)


108
109
110
# File 'lib/fig/command/options.rb', line 108

def force?()
  return @force
end

#full_help_messageObject



116
117
118
# File 'lib/fig/command/options.rb', line 116

def full_help_message()
  return @parser.full_help + EXTRA_OPTIONS_DESCRIPTION
end

#login?Boolean

Returns:

  • (Boolean)


124
125
126
# File 'lib/fig/command/options.rb', line 124

def login?()
  return @login
end

#no_figrc?Boolean

Returns:

  • (Boolean)


128
129
130
# File 'lib/fig/command/options.rb', line 128

def no_figrc?()
  return @no_figrc
end

#options_messageObject



120
121
122
# File 'lib/fig/command/options.rb', line 120

def options_message()
  return @parser.options_message + EXTRA_OPTIONS_DESCRIPTION
end

#process_command_line(argv) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/fig/command/options.rb', line 64

def process_command_line(argv)
  argv = argv.clone
  strip_shell_command(argv)

  set_up_parser()

  @parser.parse!(argv)

  if not exit_code.nil?
    return
  end

  if argv.size > 1
    $stderr.puts %q<Extra arguments. Should only have a package/version after all other options. Had "> + argv.join(%q<", ">) + %q<" left over.>
    @exit_code = 1
    return
  end

  derive_primary_descriptor(argv.first)
  if not @base_action and @descriptor
    set_base_action(Fig::Command::Action::RunCommandStatement)
  end
  set_up_sub_actions()

  actions().each {|action| action.configure(self)}

  return
end

#short_help_messageObject



112
113
114
# File 'lib/fig/command/options.rb', line 112

def short_help_message()
  return @parser.short_help
end

#suppress_warning_include_statement_missing_version?Boolean

Returns:

  • (Boolean)


132
133
134
# File 'lib/fig/command/options.rb', line 132

def suppress_warning_include_statement_missing_version?()
  return @suppress_warning_include_statement_missing_version
end