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
c6c3916d
Unverified
Commit
c6c3916d
authored
6 years ago
by
Gautham Goli
Browse files
Options
Downloads
Patches
Plain Diff
style: Use CLI::Parser to parse args
parent
fd820656
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Library/Homebrew/cli_parser.rb
+1
-1
1 addition, 1 deletion
Library/Homebrew/cli_parser.rb
Library/Homebrew/cmd/style.rb
+36
-9
36 additions, 9 deletions
Library/Homebrew/cmd/style.rb
with
37 additions
and
10 deletions
Library/Homebrew/cli_parser.rb
+
1
−
1
View file @
c6c3916d
...
...
@@ -110,7 +110,7 @@ module Homebrew
if
name
.
length
==
1
"-
#{
name
}
"
else
"--
#{
name
}
"
"--
#{
name
.
tr
(
"_"
,
"-"
)
}
"
end
end
...
...
This diff is collapsed.
Click to expand it.
Library/Homebrew/cmd/style.rb
+
36
−
9
View file @
c6c3916d
...
...
@@ -20,11 +20,41 @@
require
"json"
require
"open3"
require
"style"
require
"cli_parser"
module
Homebrew
module_function
def
style_args
Homebrew
::
CLI
::
Parser
.
new
do
usage_banner
<<~
EOS
`style` [<options>] [<files>|<taps>|<formulae>]
Check formulae or files for conformance to Homebrew style guidelines.
Lists of <files>, <taps> and <formulae> may not be combined. If none are
provided, `style` will run style checks on the whole Homebrew library,
including core code and all formulae.
EOS
switch
"--fix"
,
description:
"Fix style violations automatically using RuboCop's auto-correct feature."
switch
"--display-cop-names"
,
description:
"Include the RuboCop cop name for each violation in the output."
comma_array
"--only-cops"
,
description:
"Specify a comma-separated <cops> list to check for violations of only the "
\
"listed RuboCop cops."
comma_array
"--except-cops"
,
description:
"Specify a comma-separated <cops> list to skip checking for violations of the "
\
"listed RuboCop cops."
switch
:verbose
switch
:debug
conflicts
"--only-cops"
,
"--except-cops"
end
end
def
style
style_args
.
parse
target
=
if
ARGV
.
named
.
empty?
nil
elsif
ARGV
.
named
.
any?
{
|
file
|
File
.
exist?
file
}
...
...
@@ -35,18 +65,15 @@ module Homebrew
ARGV
.
formulae
.
map
(
&
:path
)
end
only_cops
=
ARGV
.
value
(
"only-cops"
).
to_s
.
split
(
","
)
except_cops
=
ARGV
.
value
(
"except-cops"
).
to_s
.
split
(
","
)
if
!
only_cops
.
empty?
&&
!
except_cops
.
empty?
odie
"--only-cops and --except-cops cannot be used simultaneously!"
end
only_cops
=
args
.
only_cops
except_cops
=
args
.
except_cops
options
=
{
fix:
ARGV
.
flag?
(
"--
fix
"
)
}
if
!
only_cops
.
empty?
options
=
{
fix:
args
.
fix
?
}
if
only_cops
options
[
:only_cops
]
=
only_cops
elsif
!
except_cops
.
empty?
elsif
except_cops
options
[
:except_cops
]
=
except_cops
elsif
only_cops
.
empty
?
&&
except_cops
.
empty
?
elsif
only_cops
.
nil
?
&&
except_cops
.
nil
?
options
[
:except_cops
]
=
%w[FormulaAudit
FormulaAuditStrict
NewFormulaAudit]
...
...
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