Skip to content

Support explicit CLI input format selection with --format #676

Description

@Seddryck

Summary

Add an explicit --format option to the CLI input pipeline so callers can select the input format independently of the input file extension.

Initially support:

--format csv
--format json

Motivation

The CLI should normally infer the reader from the input filename, for example:

data.csv  -> CSV reader
data.json -> JSON reader

An explicit format override is still useful when:

  • the input file has no extension;
  • the extension is misleading or non-standard;
  • input is later accepted from stdin or another source without a filename;
  • scripts should make the expected format explicit.

Expected behavior

expressif run "<expression>" --input data --format json

uses the JSON reader even though the filename has no .json extension.

Likewise:

expressif run "<expression>" --input data.txt --format csv

uses the CSV reader regardless of the .txt extension.

Resolution rules

  1. If --format is specified, it takes precedence over filename-based format detection.
  2. If --format is omitted, infer the format from the input file extension.
  3. If neither an explicit format nor a recognized extension is available, return a clear CLI error explaining that the input format cannot be determined.
  4. Reject unsupported format values through normal CLI option validation.

Scope

  • Add --format to commands that consume structured input through the common input pipeline, starting with run.
  • Support csv and json values initially.
  • Route format selection through the same reader abstraction used by automatic extension detection.
  • Add tests for explicit CSV/JSON selection, precedence over extensions, inference fallback, unknown extensions, and invalid format values.

Dependency

JSON support itself is tracked separately in #675.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementEnhancement to an existing featureepic-on-cliFeatures and enhancements about the CLI.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions