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
- If
--format is specified, it takes precedence over filename-based format detection.
- If
--format is omitted, infer the format from the input file extension.
- If neither an explicit format nor a recognized extension is available, return a clear CLI error explaining that the input format cannot be determined.
- 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.
Summary
Add an explicit
--formatoption to the CLI input pipeline so callers can select the input format independently of the input file extension.Initially support:
Motivation
The CLI should normally infer the reader from the input filename, for example:
An explicit format override is still useful when:
Expected behavior
uses the JSON reader even though the filename has no
.jsonextension.Likewise:
uses the CSV reader regardless of the
.txtextension.Resolution rules
--formatis specified, it takes precedence over filename-based format detection.--formatis omitted, infer the format from the input file extension.Scope
--formatto commands that consume structured input through the common input pipeline, starting withrun.csvandjsonvalues initially.Dependency
JSON support itself is tracked separately in #675.