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

feat(api): improve analysis cli #15027

Merged
merged 5 commits into from
Apr 26, 2024
Merged

feat(api): improve analysis cli #15027

merged 5 commits into from
Apr 26, 2024

Conversation

sfoster1
Copy link
Member

  • adds a human-json-output flag that will output formatted json that is readable
  • adds a log-output and log-level flag to pipe logs around (default is stderr)
  • adds a check flag to control return code values
  • allows specifying stdout streams with - for file paths

Closes EXEC-425

@sfoster1 sfoster1 requested a review from a team as a code owner April 26, 2024 15:48
Copy link
Member

@DerekMaggio DerekMaggio left a comment

Choose a reason for hiding this comment

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

Do we care that if they specify --json-output - --human-json-output - that it will be a whole lot of output piped to stdout? I think the answer is no, but wanted to check.

Also should add some tests for the changes in this PR

@sfoster1
Copy link
Member Author

Do we care that if they specify --json-output - --human-json-output - that it will be a whole lot of output piped to stdout? I think the answer is no, but wanted to check.

nope! if you want to do that, you can.

Also should add some tests for the changes in this PR

the changes in this pr are all interface-level changes that we don't really test for most of our code (including this one - there is no explicit testing for argument handling behavior. i'll make sure that the human-output stuff is parsable, but I don't intend to add exhaustive argument handling tests.

@sfoster1
Copy link
Member Author

okay I did add some though

- adds a human-json-output flag that will output formatted json that is
readable
- adds a log-output and log-level flag to pipe logs around (default is
stderr)
- adds a check flag to control return code values
- allows specifying stdout streams with - for file paths

Closes EXEC-425
@sfoster1 sfoster1 force-pushed the exec-425-improve-analysis-cli branch from c4dc730 to 4295882 Compare April 26, 2024 17:08
Copy link
Contributor

@mjhuff mjhuff left a comment

Choose a reason for hiding this comment

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

Nice, lgtm!

Copy link
Contributor

@SyntaxColoring SyntaxColoring left a comment

Choose a reason for hiding this comment

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

Nice.

Comment on lines 44 to 68
type=click.Path(path_type=AsyncPath),
type=click.File(mode="wb"),
Copy link
Contributor

@SyntaxColoring SyntaxColoring Apr 26, 2024

Choose a reason for hiding this comment

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

FYI, using stdout for machine-readable output is unreliable because if we're analyzing a Python protocol, it can also print to stdout, and that will corrupt the JSON stream.

Should we print() a warning if - is specified, so it will fail early and obviously if somebody tries to rely on this?

Copy link
Member Author

Choose a reason for hiding this comment

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

IMO no, but we should put a warning in the help text. Somebody will only know to use that flag by actually reading the help text, so that should be good enough.

That's a good secondary improvement too - there's no reason we can't capture stdout and save it somewhere separate.

@sfoster1 sfoster1 merged commit da4e01e into edge Apr 26, 2024
14 of 15 checks passed
@sfoster1 sfoster1 deleted the exec-425-improve-analysis-cli branch April 26, 2024 21:42
Carlos-fernandez pushed a commit that referenced this pull request May 20, 2024
- adds a human-json-output flag that will output formatted json that is
readable
- adds a log-output and log-level flag to pipe logs around (default is
stderr)
- adds a check flag to control return code values
- allows specifying stdout streams with - for file paths

Closes EXEC-425
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.

None yet

4 participants