-
Notifications
You must be signed in to change notification settings - Fork 96
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
Support yaml, yamlc output #173
Conversation
knack/output.py
Outdated
@@ -142,6 +164,8 @@ def out(self, obj, formatter=None, out_file=None): # pylint: disable=no-self-us | |||
file=out_file, end='') | |||
|
|||
def get_formatter(self, format_type): # pylint: disable=no-self-use | |||
if not sys.stdout.isatty() and format_type in ['jsonc', 'yamlc']: | |||
format_type = format_type[:-1] |
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.
format_type = format_type[:-1] [](start = 12, length = 30)
it works when you using string slice method to convert jsonc to json, but the code seems not easy to read, and if there is new type need convert like cjson->json, this code is not reusable. Can you explicitly map jsonc to json in your logic? Besides, I notice you add jsonc,ymalc in the OutputProducer._FORMAT_DICT above, what do you return different formatter here?
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.
Thank you for the suggestions. Refactored as requested. Also added test for removing color.
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.
Just one question. Even if this PR is merged, this won't work until you remove the inherited logic in azure-cli-core. Right? I mean this get_formatter
part.
yes |
Original PR Azure/azure-cli#12234
This PR:
yaml
andyamlc
output from Azure CLI to knack to unify output formats into one placeこんにちは
stdout
is a not tty, override jsonc with json, yamlc with yaml to remove color