Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
brew
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KMSCAKKSCFKA AKFACAMADCAS
brew
Commits
28e62b52
Commit
28e62b52
authored
5 years ago
by
Gautham Goli
Browse files
Options
Downloads
Patches
Plain Diff
cli_args: Remove cyclic dependency on ARGV
parent
22e25dd5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Library/Homebrew/cli/args.rb
+18
-4
18 additions, 4 deletions
Library/Homebrew/cli/args.rb
Library/Homebrew/cli/parser.rb
+4
-3
4 additions, 3 deletions
Library/Homebrew/cli/parser.rb
with
22 additions
and
7 deletions
Library/Homebrew/cli/args.rb
+
18
−
4
View file @
28e62b52
...
...
@@ -5,13 +5,14 @@ require "ostruct"
module
Homebrew
module
CLI
class
Args
<
OpenStruct
attr_accessor
:processed_options
attr_accessor
:processed_options
,
:args_parsed
# undefine tap to allow --tap argument
undef
tap
def
initialize
(
argv
:)
super
@argv
=
argv
@args_parsed
=
false
@processed_options
=
[]
end
...
...
@@ -132,7 +133,12 @@ module Homebrew
def
downcased_unique_named
# Only lowercase names, not paths, bottle filenames or URLs
remaining
.
map
do
|
arg
|
arguments
=
if
args_parsed
remaining
else
cmdline_args
.
reject
{
|
arg
|
arg
.
start_with?
(
"-"
)
}
end
arguments
.
map
do
|
arg
|
if
arg
.
include?
(
"/"
)
||
arg
.
end_with?
(
".tar.gz"
)
||
File
.
exist?
(
arg
)
arg
else
...
...
@@ -141,10 +147,18 @@ module Homebrew
end
.
uniq
end
def
head
(
args_parsed
&&
HEAD
?)
||
cmdline_args
.
include?
(
"--HEAD"
)
end
def
devel
(
args_parsed
&&
devel?
)
||
cmdline_args
.
include?
(
"--devel"
)
end
def
spec
(
default
=
:
stable
)
if
HEAD
?
if
head
:head
elsif
devel
?
elsif
devel
:devel
else
default
...
...
This diff is collapsed.
Click to expand it.
Library/Homebrew/cli/parser.rb
+
4
−
3
View file @
28e62b52
...
...
@@ -13,7 +13,7 @@ module Homebrew
attr_reader
:processed_options
,
:hide_from_man_page
def
self
.
parse
(
args
=
ARGV
,
&
block
)
new
(
&
block
).
parse
(
args
)
new
(
args
,
&
block
).
parse
(
args
)
end
def
self
.
global_options
...
...
@@ -25,10 +25,11 @@ module Homebrew
}
end
def
initialize
(
&
block
)
def
initialize
(
args
=
ARGV
,
&
block
)
@parser
=
OptionParser
.
new
@args
=
Homebrew
::
CLI
::
Args
.
new
(
argv:
ARGV_WITHOUT_MONKEY_PATCHING
)
@args
[
:remaining
]
=
[]
@args
[
:cmdline_args
]
=
args
.
dup
@constraints
=
[]
@conflicts
=
[]
@switch_sources
=
{}
...
...
@@ -139,7 +140,7 @@ module Homebrew
end
check_constraint_violations
@args
[
:remaining
]
=
remaining_args
@args_parsed
=
true
@args
.
args_parsed
=
@args_parsed
=
true
@args
.
processed_options
=
@processed_options
Homebrew
.
args
=
@args
cmdline_args
.
freeze
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment