Skip to content

feat: add format-specific CLI options#57

Merged
alvinreal merged 1 commit intomainfrom
fix/issue-28
Feb 22, 2026
Merged

feat: add format-specific CLI options#57
alvinreal merged 1 commit intomainfrom
fix/issue-28

Conversation

@alvinreal
Copy link
Owner

Adds format-specific CLI flags for fine-grained control over CSV, XML, and YAML parsing/serialization.

New CLI Options

Flag Description
--csv-delimiter <char> Custom field delimiter (\\t for tab, single char)
--csv-no-header Input CSV has no header row; returns array of arrays
--csv-header <fields> Override headers with comma-separated field names
--xml-root <name> Root element name for XML output (default: root)
--xml-attr-prefix <prefix> Attribute prefix for XML (default: @)
--yaml-multi Force multi-document mode (always returns array)

Implementation Details

  • CLI struct extended with format-specific fields via clap
  • parse_input_with_cli / serialize_output_with_cli pass CLI options to format handlers
  • from_str_with_explicit_headers added to CSV module for header override
  • from_str_multi added to YAML module for forced multi-doc mode
  • Format options silently ignored when not relevant (no errors for --xml-root on JSON→JSON)

Tests

8 integration tests covering:

  • Tab-delimited CSV (--csv-delimiter)
  • Headerless CSV (--csv-no-header)
  • Header override (--csv-header)
  • Custom XML root element (--xml-root)
  • Custom XML attribute prefix (--xml-attr-prefix)
  • YAML multi-document mode (--yaml-multi)
  • Single-doc YAML with --yaml-multi (wraps in array)
  • Options ignored when unused format

Fixes #28

Adds CLI flags for format-specific configuration:
- --csv-delimiter: custom field delimiter (supports \t for tab)
- --csv-no-header: input CSV has no header row (returns arrays)
- --csv-header: override CSV headers with comma-separated names
- --xml-root: custom root element name for XML output
- --xml-attr-prefix: custom attribute prefix for XML (default @)
- --yaml-multi: force multi-document mode (always returns array)

All options are format-aware and silently ignored when not applicable.
Includes 8 integration tests covering all options and edge cases.

Fixes #28
@alvinreal alvinreal merged commit ca37b8a into main Feb 22, 2026
6 checks passed
@alvinreal alvinreal deleted the fix/issue-28 branch February 22, 2026 10:39
@github-actions github-actions bot mentioned this pull request Mar 20, 2026
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.

Format-specific CLI options

1 participant