Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pretty table printing #360

Merged
merged 3 commits into from
Mar 29, 2021
Merged

Pretty table printing #360

merged 3 commits into from
Mar 29, 2021

Conversation

soutaro
Copy link
Owner

@soutaro soutaro commented Mar 27, 2021

steep stats now support table and csv printing modes. Users can specify the mode through --format options.

$ steep stats --format=table
 Target  File                                         Status   Typed calls  Untyped calls  All calls  Typed %
--------------------------------------------------------------------------------------------------------------
 test    argument_type_mismatch.rb                    success            0              0          1       0%
 test    block_body_type_mismatch.rb                  success            1              0          2      50%
 test    block_type_mismatch.rb                       success            0              2          3       0%
 test    break_type_mismatch.rb                       success            1              0          1     100%

The default mode depends on STDOUT.tty?. table mode is used if it's true and csv mode is used if it's false. This assumes a workflow to run steep stats command behind a pipe and save the result as a CSV file for further visualization/review/processing. This PR won't break the workflow.

@soutaro soutaro linked an issue Mar 27, 2021 that may be closed by this pull request
lib/steep/cli.rb Outdated
when "csv", "table"
check.format = format
else
stderr.puts "--format option is ignored because it has unknown value: `#{format}`"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[IMO] Since ArgumentError occurs on an invalid --log-level value, it seems kind to me to raise ArgumentError also on an invalid --format value.

Error:

$ bundle exec steep stats --log-level=fata
#<ArgumentError: invalid log level: data>

No error:

$ bundle exec steep stats --log-level=fatal --format=tabl
--format option is ignored because it has unknown value: `tabl`
# Calculating stats:

 Target  File                                             Status   Typed calls  Untyped calls  All calls  Typed %
------------------------------------------------------------------------------------------------------------------
...

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Will do. 💪

Let the driver raise an error.
@soutaro soutaro merged commit 7147e5b into master Mar 29, 2021
@soutaro soutaro deleted the terminal-table branch March 29, 2021 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve formatting for steep stats
2 participants