Class: Fig::Command::Options
- Inherits:
-
Object
- Object
- Fig::Command::Options
- Defined in:
- lib/fig/command/options.rb
Overview
Command-line processing.
Constant Summary collapse
- USAGE =
<<-EOF Usage: fig [...] [DESCRIPTOR] [--update | --update-if-missing] [-- COMMAND] fig [...] [DESCRIPTOR] [--update | --update-if-missing] [--command-extra-args VALUES] fig {--publish | --publish-local} DESCRIPTOR [--resource PATH] [--archive PATH] [--include DESCRIPTOR] [--override DESCRIPTOR] [--force] [...] fig --clean DESCRIPTOR [...] fig --get VARIABLE [DESCRIPTOR] [...] fig --list-configs [DESCRIPTOR] [...] fig --list-dependencies [--list-tree] [--list-all-configs] [DESCRIPTOR] [...] fig --list-variables [--list-tree] [--list-all-configs] [DESCRIPTOR] [...] fig {--list-local | --list-remote} [...] fig {--version | --help} A DESCRIPTOR looks like <package name>[/<version>][:<config>] e.g. "foo", "foo/1.2.3", and "foo/1.2.3:default". Whether ":<config>" and "/<version>" are required or allowed is dependent upon what your are doing. Standard options (represented as "[...]" above): [--set VARIABLE=VALUE] [--append VARIABLE=VALUE] [--file PATH] [--no-file] [--config CONFIG] [--login] [--log-level LEVEL] [--log-config PATH] [--figrc PATH] [--no-figrc] [--suppress-warning-include-statement-missing-version] Environment variables: FIG_REMOTE_URL (required), FIG_HOME (path to local repository cache, defaults to $HOME/.fighome). EOF
- LOG_LEVELS =
%w[ off fatal error warn info debug all ]
- LOG_ALIASES =
{ 'warning' => 'warn' }
Instance Attribute Summary collapse
-
#command_extra_argv ⇒ Object
readonly
Returns the value of attribute command_extra_argv.
-
#descriptor ⇒ Object
readonly
Returns the value of attribute descriptor.
-
#exit_code ⇒ Object
readonly
Returns the value of attribute exit_code.
-
#shell_command ⇒ Object
readonly
Returns the value of attribute shell_command.
Instance Method Summary collapse
- #archives ⇒ Object
- #clean? ⇒ Boolean
- #config ⇒ Object
- #environment_statements ⇒ Object
- #figrc ⇒ Object
- #force? ⇒ Boolean
- #get ⇒ Object
-
#help ⇒ Object
This needs to be public for efficient use of custom command.rb wrappers.
- #help? ⇒ Boolean
- #home ⇒ Object
-
#initialize(argv) ⇒ Options
constructor
A new instance of Options.
- #list_all_configs? ⇒ Boolean
- #list_tree? ⇒ Boolean
- #listing ⇒ Object
- #log_config ⇒ Object
- #log_level ⇒ Object
- #login? ⇒ Boolean
- #no_figrc? ⇒ Boolean
- #package_definition_file ⇒ Object
- #publish? ⇒ Boolean
- #publish_local? ⇒ Boolean
- #publishing? ⇒ Boolean
-
#reset_environment? ⇒ Boolean
Answers whether we should reset the environment to nothing, sort of like the standardized environment that cron(1) creates.
- #resources ⇒ Object
-
#strip_shell_command(argv) ⇒ Object
This needs to be public for efficient use of custom command.rb wrappers.
- #suppress_warning_include_statement_missing_version? ⇒ Boolean
- #update? ⇒ Boolean
- #update_if_missing? ⇒ Boolean
- #updating? ⇒ Boolean
- #version? ⇒ Boolean
Constructor Details
#initialize(argv) ⇒ Options
Returns a new instance of Options.
71 72 73 |
# File 'lib/fig/command/options.rb', line 71 def initialize(argv) process_command_line(argv) end |
Instance Attribute Details
#command_extra_argv ⇒ Object (readonly)
Returns the value of attribute command_extra_argv.
67 68 69 |
# File 'lib/fig/command/options.rb', line 67 def command_extra_argv @command_extra_argv end |
#descriptor ⇒ Object (readonly)
Returns the value of attribute descriptor.
68 69 70 |
# File 'lib/fig/command/options.rb', line 68 def descriptor @descriptor end |
#exit_code ⇒ Object (readonly)
Returns the value of attribute exit_code.
69 70 71 |
# File 'lib/fig/command/options.rb', line 69 def exit_code @exit_code end |
#shell_command ⇒ Object (readonly)
Returns the value of attribute shell_command.
66 67 68 |
# File 'lib/fig/command/options.rb', line 66 def shell_command @shell_command end |
Instance Method Details
#archives ⇒ Object
75 76 77 |
# File 'lib/fig/command/options.rb', line 75 def archives() return @options[:archives] end |
#clean? ⇒ Boolean
79 80 81 |
# File 'lib/fig/command/options.rb', line 79 def clean?() return @options[:clean] end |
#config ⇒ Object
83 84 85 |
# File 'lib/fig/command/options.rb', line 83 def config() return @options[:config] end |
#environment_statements ⇒ Object
135 136 137 |
# File 'lib/fig/command/options.rb', line 135 def environment_statements() return @options[:environment_statements] end |
#figrc ⇒ Object
87 88 89 |
# File 'lib/fig/command/options.rb', line 87 def figrc() return @options[:figrc] end |
#force? ⇒ Boolean
91 92 93 |
# File 'lib/fig/command/options.rb', line 91 def force?() return @options[:force] end |
#get ⇒ Object
95 96 97 |
# File 'lib/fig/command/options.rb', line 95 def get() return @options[:get] end |
#help ⇒ Object
This needs to be public for efficient use of custom command.rb wrappers.
213 214 215 216 217 218 219 220 221 222 223 |
# File 'lib/fig/command/options.rb', line 213 def help() puts @help_message puts <<-'END_MESSAGE' -- end of Fig options; anything after this is used as a command to run --command-extra-args end of Fig options; anything after this is appended to the end of a "command" statement in a "config" block. END_MESSAGE return 0 end |
#help? ⇒ Boolean
99 100 101 |
# File 'lib/fig/command/options.rb', line 99 def help?() return @options[:help] end |
#home ⇒ Object
103 104 105 |
# File 'lib/fig/command/options.rb', line 103 def home() return @options[:home] end |
#list_all_configs? ⇒ Boolean
115 116 117 |
# File 'lib/fig/command/options.rb', line 115 def list_all_configs?() return @options[:list_all_configs] end |
#list_tree? ⇒ Boolean
111 112 113 |
# File 'lib/fig/command/options.rb', line 111 def list_tree?() return @options[:list_tree] end |
#listing ⇒ Object
107 108 109 |
# File 'lib/fig/command/options.rb', line 107 def listing() return @options[:listing] end |
#log_config ⇒ Object
119 120 121 |
# File 'lib/fig/command/options.rb', line 119 def log_config() return @options[:log_config] end |
#log_level ⇒ Object
127 128 129 |
# File 'lib/fig/command/options.rb', line 127 def log_level() return @options[:log_level] end |
#login? ⇒ Boolean
123 124 125 |
# File 'lib/fig/command/options.rb', line 123 def login?() return @options[:login] end |
#no_figrc? ⇒ Boolean
131 132 133 |
# File 'lib/fig/command/options.rb', line 131 def no_figrc?() return @options[:no_figrc] end |
#package_definition_file ⇒ Object
139 140 141 |
# File 'lib/fig/command/options.rb', line 139 def package_definition_file() return @options[:package_definition_file] end |
#publish? ⇒ Boolean
143 144 145 |
# File 'lib/fig/command/options.rb', line 143 def publish?() return @options[:publish] end |
#publish_local? ⇒ Boolean
147 148 149 |
# File 'lib/fig/command/options.rb', line 147 def publish_local?() return @options[:publish_local] end |
#publishing? ⇒ Boolean
151 152 153 |
# File 'lib/fig/command/options.rb', line 151 def publishing?() return publish? || publish_local? end |
#reset_environment? ⇒ Boolean
Answers whether we should reset the environment to nothing, sort of like the standardized environment that cron(1) creates. At present, we’re only setting this when we’re listing variables. One could imagine allowing this to be set by a command-line option in general; if we do this, the Environment class will need to be changed to support deletion of values from ENV.
185 186 187 |
# File 'lib/fig/command/options.rb', line 185 def reset_environment?() return listing() == :variables end |
#resources ⇒ Object
155 156 157 |
# File 'lib/fig/command/options.rb', line 155 def resources() return @options[:resources] end |
#strip_shell_command(argv) ⇒ Object
This needs to be public for efficient use of custom command.rb wrappers.
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/fig/command/options.rb', line 190 def strip_shell_command(argv) argv.each_with_index do |arg, i| terminating_option = nil case arg when '--' terminating_option = arg @shell_command = argv[(i+1)..-1] when '--command-extra-args' terminating_option = arg @command_extra_argv = argv[(i+1)..-1] end if terminating_option argv.slice!(i..-1) break end end return end |
#suppress_warning_include_statement_missing_version? ⇒ Boolean
159 160 161 |
# File 'lib/fig/command/options.rb', line 159 def suppress_warning_include_statement_missing_version?() return @options[:suppress_warning_include_statement_missing_version] end |
#update? ⇒ Boolean
163 164 165 |
# File 'lib/fig/command/options.rb', line 163 def update?() return @options[:update] end |
#update_if_missing? ⇒ Boolean
167 168 169 |
# File 'lib/fig/command/options.rb', line 167 def update_if_missing?() return @options[:update_if_missing] end |
#updating? ⇒ Boolean
171 172 173 |
# File 'lib/fig/command/options.rb', line 171 def updating?() return update? || update_if_missing? end |
#version? ⇒ Boolean
175 176 177 |
# File 'lib/fig/command/options.rb', line 175 def version?() return @options[:version] end |