Skip to content

Add --format option to CLI commands supporting --csv#1062

Merged
stevemessick merged 3 commits into
mainfrom
add-format-option
Jun 15, 2026
Merged

Add --format option to CLI commands supporting --csv#1062
stevemessick merged 3 commits into
mainfrom
add-format-option

Conversation

@stevemessick

Copy link
Copy Markdown
Contributor

Add --format option to CLI commands supporting --csv

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

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
@stevemessick stevemessick requested a review from rosbo June 12, 2026 19:13
@stevemessick

Copy link
Copy Markdown
Contributor Author

First phase of adding JSON format: allow the option but don't implement the new format.

Comment thread docs/output_format.md
@@ -0,0 +1,89 @@
# Kaggle CLI Output Formatting Documentation

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks! I should have done that.

Comment thread docs/output_format.md

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's under consideration for a future PR.

Comment thread docs/output_format.md
* `kaggle datasets list`
* `kaggle datasets files`
* `kaggle datasets topics list`
* `kaggle datasets topics show`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you make sure kaggle datasets status reuse the same logic: #972

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@stevemessick stevemessick requested a review from rosbo June 15, 2026 21:50
@stevemessick stevemessick merged commit 5a549dc into main Jun 15, 2026
14 checks passed
@stevemessick stevemessick deleted the add-format-option branch June 15, 2026 22:27
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.

2 participants