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

Dropping support for --json and --compact and adding support for --output-format #266

Merged
merged 3 commits into from
Nov 5, 2021

Conversation

mayuriesha
Copy link
Contributor

@mayuriesha mayuriesha commented Nov 4, 2021

To help us get this pull request reviewed and merged quickly, please be sure to include the following items:

  • Tests (if applicable)
  • Documentation (if applicable)
  • Changelog entry
  • A full explanation here in the PR description of the work done

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Tests
  • Other

Backward Compatibility

Is this change backward compatible with the most recently released version? Does it introduce changes which might change the user experience in any way? Does it alter the API in any way?

  • Yes (backward compatible)
  • No (breaking changes)

Issue Linking

closes #253

What's new?

  • The PR drops support for --json and --compact options and instead uses single flag --output-format json/compact/text to support different output formats

@mayuriesha mayuriesha requested a review from a team as a code owner November 4, 2021 19:28
@mayuriesha mayuriesha changed the title Dropping support for --json and --compact and adding support for --ou… Dropping support for --json and --compact and adding support for --output-format Nov 4, 2021
Copy link
Contributor

@tarkatronic tarkatronic left a comment

Choose a reason for hiding this comment

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

Just a couple of small changes here. The more I see this, the more I love the decision to make this change!

One thing I'm wondering as I look through this code though -- does it make sense to make an enum? I always hate having to pass around magical string values where typoes could get introduced. What about a types.OutputFormat? I'm very much open to arguments either way on this. 😄

tartufo/cli.py Outdated
"--output-format",
type=click.Choice(["json", "compact", "text"]),
default="text",
help="Output can be in json/compact/text format. By default the output will be in text format.",
Copy link
Contributor

Choose a reason for hiding this comment

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

I really like the description you added to the README.md for this option -- can you put that in here?

@@ -68,12 +68,12 @@ def __init__(
self.chunk = chunk
self.logger = logging.getLogger(__name__)

def as_dict(self, compact=False) -> Dict[str, Optional[str]]:
def as_dict(self, output_format=None) -> Dict[str, Optional[str]]:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it makes the most sense to keep this method the way it was, using a boolean. Since the other values of output_format mean nothing to this, a boolean seems cleanest.

Copy link
Contributor

@sushantmimani sushantmimani left a comment

Choose a reason for hiding this comment

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

LGTM, once @tarkatronic's comments have been addressed.

@tarkatronic tarkatronic linked an issue Nov 4, 2021 that may be closed by this pull request
Copy link
Contributor

@tarkatronic tarkatronic left a comment

Choose a reason for hiding this comment

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

Looks great!

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.

Consolidate output options into --output-format / -of flag
3 participants