Skip to content

Commit

Permalink
fix: improve cli output (#44)
Browse files Browse the repository at this point in the history
Before:

```
❯ bundle exec rake dev:annotate

Chusaku has finished running.
Model files unchanged.

❯ bundle exec rake dev:annotate
Nothing to annotate.
Model files unchanged.
```

After:

```
❯ bundle exec rake dev:annotate
Chusaku has finished running.
Model files unchanged.

❯ bundle exec rake dev:annotate
Controller files unchanged.
Model files unchanged.
```

I've also preserved the newline before the final output line if
`--verbose` is passed.

Resolves #42
  • Loading branch information
G-Rath authored Jan 5, 2024
1 parent c35763b commit 82d9e22
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/chusaku.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,10 @@ def output_results
#
# @return [String] Copy to be outputted to user
def output_copy
return "Nothing to annotate." if @changed_files.empty?
return "Controller files unchanged." if @changed_files.empty?

copy = changes_copy
copy += "\nChusaku has finished running."
copy += "Chusaku has finished running."
copy += "\nThis was a dry run so no files were changed." if @flags.include?(:dry)
copy += "\nExited with status code 1." if @flags.include?(:error_on_annotation)
copy
Expand All @@ -229,7 +229,7 @@ def changes_copy
#{change[:new_body].chomp}
```
CHANGE_OUTPUT
end.join("\n")
end.join("\n") + "\n"
end
end
end
4 changes: 2 additions & 2 deletions test/chusaku_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def test_mock_app_with_no_pending_annotations

assert_equal(0, exit_code)
assert_empty(File.written_files)
assert_equal("Nothing to annotate.\n", out)
assert_equal("Controller files unchanged.\n", out)
end

def test_mock_app_with_non_matching_controllers_pattern
Expand All @@ -153,6 +153,6 @@ def test_mock_app_with_non_matching_controllers_pattern

assert_equal(0, exit_code)
assert_empty(File.written_files)
assert_equal("Nothing to annotate.\n", out)
assert_equal("Controller files unchanged.\n", out)
end
end

0 comments on commit 82d9e22

Please sign in to comment.