Conversation
knack/output.py
Outdated
|
|
||
| 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.
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.
Thank you for the suggestions. Refactored as requested. Also added test for removing color.
mmyyrroonn
left a comment
There was a problem hiding this comment.
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:
yamlandyamlcoutput from Azure CLI to knack to unify output formats into one placeこんにちはstdoutis a not tty, override jsonc with json, yamlc with yaml to remove color