Method: Beaker::Options::Parser#parse_args
- Defined in:
- lib/beaker/options/parser.rb
#parse_args(args = ARGV) ⇒ Object
Parses ARGV or provided arguments array, file options, hosts options and combines with environment variables and preset defaults to generate a Hash representing the Beaker options for a given test run
Order of priority is as follows:
1. environment variables are given top priority
2. ARGV or provided arguments array
3. the 'CONFIG' section of the hosts file
4. file values
5. subcommand , if executing beaker subcommands
6. subcommand from $HOME/.beaker/.yaml
7. project values in .beaker.yml
8. default or preset values are given the lowest priority
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
# File 'lib/beaker/options/parser.rb', line 214 def parse_args(args = ARGV) = @presets.presets @attribution = @attribution.merge(tag_sources(@presets.presets, "preset")) = @command_line_parser.parse(args) [:command_line] = ([$0] + args).join(' ') @attribution = @attribution.merge(tag_sources(, "flag")) # Merge options in reverse precedence order. First project options, # then global options from $HOME/.beaker/subcommand_options.yaml, # then subcommand options in the project. = Beaker::Subcommands::SubcommandUtil::SUBCOMMAND_OPTIONS { "project" => ".beaker.yml", "homedir" => "#{ENV['HOME']}/#{subcommand_options_file}", "subcommand" => , }.each_pair do |src, path| opts = if src == "project" Beaker::Options::SubcommandOptionsParser.(path) else Beaker::Options::SubcommandOptionsParser.(args, path) end @attribution = @attribution.merge(tag_sources(opts, src)) .merge!(opts) end = Beaker::Options::OptionsFileParser.([:options_file] || [:options_file]) @attribution = @attribution.merge(tag_sources(, "options_file")) # merge together command line and file_options # overwrite file options with command line options = .merge() # merge command line and file options with defaults # overwrite defaults with command line and file options = .merge() if not [:help] and not [:beaker_version_print] = # merge in host file vars # overwrite options (default, file options, command line) with host file options = .merge() @attribution = @attribution.merge(tag_sources(, "host_file")) # re-merge the command line options # overwrite options (default, file options, hosts file ) with command line arguments = .merge() @attribution = @attribution.merge(tag_sources(, "cmd")) # merge in env vars # overwrite options (default, file options, command line, hosts file) with env env_vars = @presets.env_vars = .merge(env_vars) @attribution = @attribution.merge(tag_sources(env_vars, "env")) normalize_args end end |