Class: Homebrew::CLI::Args
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Homebrew::CLI::Args
- Defined in:
- Library/Homebrew/cli/args.rb
Instance Attribute Summary collapse
-
#flags_only ⇒ Object
readonly
Returns the value of attribute flags_only.
-
#options_only ⇒ Object
readonly
Returns the value of attribute options_only.
Instance Method Summary collapse
- #build_from_source_formulae ⇒ Object
- #build_stable? ⇒ Boolean
- #casks ⇒ Object
- #context ⇒ Object
- #formulae ⇒ Object
- #formulae_and_casks ⇒ Object
- #formulae_paths ⇒ Object
- #freeze_named_args!(named_args) ⇒ Object
- #freeze_processed_options!(processed_options) ⇒ Object
- #freeze_remaining_args!(remaining_args) ⇒ Object
- #include_test_formulae ⇒ Object
-
#initialize ⇒ Args
constructor
A new instance of Args.
- #kegs ⇒ Object
- #kegs_casks ⇒ Object
- #loaded_casks ⇒ Object
- #named ⇒ Object
- #no_named? ⇒ Boolean
- #resolved_formulae ⇒ Object
- #resolved_formulae_casks ⇒ Object
- #value(name) ⇒ Object
Constructor Details
#initialize ⇒ Args
Returns a new instance of Args.
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'Library/Homebrew/cli/args.rb', line 15 def initialize super() @processed_options = [] @options_only = [] @flags_only = [] # Can set these because they will be overwritten by freeze_named_args! # (whereas other values below will only be overwritten if passed). self[:named_args] = NamedArgs.new(parent: self) self[:remaining] = [] end |
Instance Attribute Details
#flags_only ⇒ Object (readonly)
Returns the value of attribute flags_only
10 11 12 |
# File 'Library/Homebrew/cli/args.rb', line 10 def flags_only @flags_only end |
#options_only ⇒ Object (readonly)
Returns the value of attribute options_only
10 11 12 |
# File 'Library/Homebrew/cli/args.rb', line 10 def @options_only end |
Instance Method Details
#build_from_source_formulae ⇒ Object
110 111 112 113 114 115 116 |
# File 'Library/Homebrew/cli/args.rb', line 110 def build_from_source_formulae if build_from_source? || build_bottle? named.to_formulae.map(&:full_name) else [] end end |
#build_stable? ⇒ Boolean
106 107 108 |
# File 'Library/Homebrew/cli/args.rb', line 106 def build_stable? !HEAD? end |
#casks ⇒ Object
86 87 88 89 |
# File 'Library/Homebrew/cli/args.rb', line 86 def casks odeprecated "args.casks", "args.named.homebrew_tap_cask_names" named.homebrew_tap_cask_names end |
#context ⇒ Object
134 135 136 |
# File 'Library/Homebrew/cli/args.rb', line 134 def context Context::ContextStruct.new(debug: debug?, quiet: quiet?, verbose: verbose?) end |
#formulae ⇒ Object
61 62 63 64 |
# File 'Library/Homebrew/cli/args.rb', line 61 def formulae odeprecated "args.formulae", "args.named.to_formulae" named.to_formulae end |
#formulae_and_casks ⇒ Object
66 67 68 69 |
# File 'Library/Homebrew/cli/args.rb', line 66 def formulae_and_casks odeprecated "args.formulae_and_casks", "args.named.to_formulae_and_casks" named.to_formulae_and_casks end |
#formulae_paths ⇒ Object
81 82 83 84 |
# File 'Library/Homebrew/cli/args.rb', line 81 def formulae_paths odeprecated "args.formulae_paths", "args.named.to_formulae_paths" named.to_formulae_paths end |
#freeze_named_args!(named_args) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'Library/Homebrew/cli/args.rb', line 32 def freeze_named_args!(named_args) self[:named_args] = NamedArgs.new( *named_args.freeze, override_spec: spec(nil), force_bottle: force_bottle?, flags: flags_only, parent: self, ) end |
#freeze_processed_options!(processed_options) ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'Library/Homebrew/cli/args.rb', line 42 def () # Reset cache values reliant on processed_options @cli_args = nil @processed_options += @processed_options.freeze @options_only = cli_args.select { |a| a.start_with?("-") }.freeze @flags_only = cli_args.select { |a| a.start_with?("--") }.freeze end |
#freeze_remaining_args!(remaining_args) ⇒ Object
28 29 30 |
# File 'Library/Homebrew/cli/args.rb', line 28 def freeze_remaining_args!(remaining_args) self[:remaining] = remaining_args.freeze end |
#include_test_formulae ⇒ Object
118 119 120 121 122 123 124 |
# File 'Library/Homebrew/cli/args.rb', line 118 def include_test_formulae if include_test? named.to_formulae.map(&:full_name) else [] end end |
#kegs ⇒ Object
96 97 98 99 |
# File 'Library/Homebrew/cli/args.rb', line 96 def kegs odeprecated "args.kegs", "args.named.to_kegs" named.to_kegs end |
#kegs_casks ⇒ Object
101 102 103 104 |
# File 'Library/Homebrew/cli/args.rb', line 101 def kegs_casks odeprecated "args.kegs", "args.named.to_kegs_to_casks" named.to_kegs_to_casks end |
#loaded_casks ⇒ Object
91 92 93 94 |
# File 'Library/Homebrew/cli/args.rb', line 91 def loaded_casks odeprecated "args.loaded_casks", "args.named.to_cask" named.to_casks end |
#named ⇒ Object
53 54 55 |
# File 'Library/Homebrew/cli/args.rb', line 53 def named named_args end |
#no_named? ⇒ Boolean
57 58 59 |
# File 'Library/Homebrew/cli/args.rb', line 57 def no_named? named.blank? end |
#resolved_formulae ⇒ Object
71 72 73 74 |
# File 'Library/Homebrew/cli/args.rb', line 71 def resolved_formulae odeprecated "args.resolved_formulae", "args.named.to_resolved_formulae" named.to_resolved_formulae end |
#resolved_formulae_casks ⇒ Object
76 77 78 79 |
# File 'Library/Homebrew/cli/args.rb', line 76 def resolved_formulae_casks odeprecated "args.resolved_formulae_casks", "args.named.to_resolved_formulae_to_casks" named.to_resolved_formulae_to_casks end |
#value(name) ⇒ Object
126 127 128 129 130 131 132 |
# File 'Library/Homebrew/cli/args.rb', line 126 def value(name) arg_prefix = "--#{name}=" flag_with_value = flags_only.find { |arg| arg.start_with?(arg_prefix) } return unless flag_with_value flag_with_value.delete_prefix(arg_prefix) end |