-
Notifications
You must be signed in to change notification settings - Fork 446
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(names) add --format option #4778
feat(names) add --format option #4778
Conversation
I added the email address on the commits to Launchpad several hours ago in the hope that the CLA check would validate correctly... Update: I have subsequently signed the CLA again to see if the database will store it now that the email address is in Launchpad |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, thanks for another contribution!
db96a5e
to
02612bd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This looks fairly similar to how Charmcraft does this, but with some improvements I'll probably be copying over :-)
@DanielDewberry if you have opinions on a general case for this on more commands (e.g. |
Thank you, that's a compliment and a half :) |
Add --format option to snapcraft names to enable output format selection. Possible choices are: - table (default, existing behaviour) - json (pretty print with 4sp indent) tests/unit/commands/test_names.py: - Add test class TestNames. - Rename test_names to test_table and move it into the scope of TestName. Add format to argparse.Namespace. - Add test_json to TestNames. - Add test_format_error to TestNames.
dcd7b8d
to
8353980
Compare
Add --format option to snapcraft names to enable output format selection. Possible choices are:
tests/unit/commands/test_names.py:
Add test class TestNames.
Rename test_names to test_table and move it into the scope of TestName. Add format to argparse.Namespace.
Add test_json to TestNames.
Have you followed the guidelines for contributing?
Have you signed the CLA?
Have you successfully run
tox run -m lint
?Have you successfully run
tox run -e test-py310
? (supported versions:py39
,py310
,py311
,py312
)The motivation for adding JSON formatted output to the names sub-command, is that of data pipelines. It will enable tooling to read the command output and leverage JSON parsers rather than performing text processing. A small quality of life improvement :)
The JSON structure leaves room for extension if subsequently required: