Add --format option to CLI commands supporting --csv#1062
Conversation
This change introduces a new `--format` option to all Kaggle CLI commands that previously supported the `--csv` option. The `--format` option accepts 'csv', 'table', or 'json' as values. The `--csv` and `--format` options are mutually exclusive. Internally, the `KaggleApi` class has been updated to use a new `OutputFormat` enum and `_get_output_format` helper method to resolve the desired output format. All `_cli` methods have been updated to branch based on this enum. Currently, 'json' format prints a 'not yet implemented' warning. Added tests for argparse validation and output formatting. Updated documentation with examples. TAG=agy CONV=8eb2e998-74be-49e0-8f0f-e84eaad7bda0
|
First phase of adding JSON format: allow the option but don't implement the new format. |
| @@ -0,0 +1,89 @@ | |||
| # Kaggle CLI Output Formatting Documentation | |||
There was a problem hiding this comment.
Should we rename this file formatting.md or options.md? Also, we should link to it from the main doc otherwise user will never find it.
There was a problem hiding this comment.
Thanks! I should have done that.
|
|
||
| We have introduced a new `--format` option to provide a unified way to specify the output format. | ||
| It accepts the following values: | ||
| * `csv`: Display output as comma-separated values. |
There was a problem hiding this comment.
Are you planning to also support the column selection optional feature like gcloud? https://screenshot.googleplex.com/9fMMye6g77pjRiq
The existing datasets status command (only command supporting the format flags supports this too): #972
There was a problem hiding this comment.
It's under consideration for a future PR.
| * `kaggle datasets list` | ||
| * `kaggle datasets files` | ||
| * `kaggle datasets topics list` | ||
| * `kaggle datasets topics show` |
There was a problem hiding this comment.
Can you make sure kaggle datasets status reuse the same logic: #972
There was a problem hiding this comment.
Add --format option to CLI commands supporting --csv
This change introduces a new
--formatoption to all Kaggle CLI commandsthat previously supported the
--csvoption. The--formatoptionaccepts 'csv', 'table', or 'json' as values.
The
--csvand--formatoptions are mutually exclusive.Internally, the
KaggleApiclass has been updated to use a newOutputFormatenum and
_get_output_formathelper method to resolve the desired outputformat. All
_climethods have been updated to branch based on this enum.Currently, 'json' format prints a 'not yet implemented' warning.
Added tests for argparse validation and output formatting.
Updated documentation with examples.
TAG=agy
CONV=8eb2e998-74be-49e0-8f0f-e84eaad7bda0