Skip to content

Commit

Permalink
Implement packwerk show-offenses command
Browse files Browse the repository at this point in the history
  • Loading branch information
davidstosik committed Mar 30, 2023
1 parent d8ca547 commit 0962193
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/packwerk/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def execute_command(args)
output_result(parse_run(args).check)
when "update-todo", "update"
output_result(parse_run(args).update_todo)
when "show-offenses", "show"
output_result(parse_run(args).show_offenses)
when "validate"
validate(args)
when "version"
Expand Down Expand Up @@ -118,6 +120,7 @@ def usage
Subcommands:
init - set up packwerk
check - run all checks
show-offenses - displays all offenses
update-todo - update package_todo.yml files
validate - verify integrity of packwerk and package configuration
version - output packwerk version
Expand Down
10 changes: 10 additions & 0 deletions lib/packwerk/parse_run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ def update_todo
Cli::Result.new(message: message, status: offense_collection.errors.empty?)
end

sig { returns(Cli::Result) }
def show_offenses
run_context = RunContext.from_configuration(@configuration)
all_offenses = find_offenses(run_context)

message = @offenses_formatter.show_offenses(all_offenses)

Cli::Result.new(message: message, status: true)
end

sig { returns(Cli::Result) }
def check
run_context = RunContext.from_configuration(@configuration)
Expand Down

0 comments on commit 0962193

Please sign in to comment.