Skip to content

Commit

Permalink
Add command line option
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Evanczuk committed Nov 22, 2022
1 parent 761a83f commit 239ec66
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,10 @@ Then in `packwerk.yml`, you can set the `formatter` to the identifier for your c
formatter: my_offenses_formatter
```

You can also pass in a formatter on the command line:
```
bin/packwerk check --format=my_offenses_formatter
```
### Privacy Checker

[`packwerk-extensions`](https://github.com/rubyatscale/packwerk-extensions) (originally extracted from `packwerk`) can be used to help define and enforce public API boundaries of a package. See the README.md for more details. To use this, add it to your `Gemfile` and then require it via `packwerk.yml`:
Expand Down
11 changes: 10 additions & 1 deletion lib/packwerk/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ def list_validation_errors(result)
def parse_run(params)
relative_file_paths = T.let([], T::Array[String])
ignore_nested_packages = nil
formatter = @offenses_formatter

if params.any? { |p| p.include?("--packages") }
OptionParser.new do |parser|
Expand All @@ -195,11 +196,19 @@ def parse_run(params)
ignore_nested_packages = false
end

if params.any? { |p| p.include?("--format") }
OptionParser.new do |parser|
parser.on("--format=FORMATTER", String, "name of formatter to use") do |formatter_identifier|
formatter = OffensesFormatter.find(formatter_identifier)
end
end.parse!(params)
end

ParseRun.new(
relative_file_set: fetch_files_to_process(relative_file_paths, ignore_nested_packages),
configuration: @configuration,
progress_formatter: @progress_formatter,
offenses_formatter: @offenses_formatter
offenses_formatter: formatter
)
end
end
Expand Down

0 comments on commit 239ec66

Please sign in to comment.