Skip to content

feat: add -m, -e, and --dry-run CLI mapping flags#48

Merged
alvinreal merged 1 commit intomainfrom
fix/issue-19
Feb 21, 2026
Merged

feat: add -m, -e, and --dry-run CLI mapping flags#48
alvinreal merged 1 commit intomainfrom
fix/issue-19

Conversation

@alvinreal
Copy link
Copy Markdown
Owner

Summary

Adds mapping support to the CLI with three new flags, completing issue #19.

New Flags

  • -m / --mapping <file> — Load and apply a .morph mapping file
  • -e / --expr <expression> — Inline mapping expression (repeatable, applied in order)
  • --dry-run — Parse and validate the mapping without executing

Behavior

  • Multiple -e flags combine in order
  • -m and -e can be combined: file operations apply first, then inline expressions
  • No mapping flags → straight passthrough conversion (unchanged behavior)

Tests

Unit tests (in src/cli.rs):

  • arg_parsing_mapping_file-m flag parses correctly
  • arg_parsing_single_expr — Single -e flag
  • arg_parsing_multiple_expr — Multiple -e flags
  • arg_parsing_dry_run--dry-run flag
  • arg_parsing_mapping_and_expr_combined-m + -e together
  • no_mapping_flags_returns_none — No flags → None
  • build_mapping_from_expr — Builds program from -e
  • build_mapping_multiple_exprs_in_order — Multiple exprs produce correct statement count
  • build_mapping_invalid_expr_returns_error — Bad syntax → error
  • build_mapping_nonexistent_file_returns_error — Missing file → error

Integration tests (in tests/cli_mapping.rs):

  • mapping_file_applies_transformations-m with valid file
  • mapping_file_nonexistent_gives_error-m with missing file
  • mapping_file_invalid_syntax_gives_parser_error-m with bad syntax
  • single_expr_works-e with one expression
  • multiple_expr_apply_in_order — Multiple -e in sequence
  • mapping_and_expr_combined-m + -e end-to-end
  • dry_run_valid_mapping_reports_valid--dry-run with valid mapping
  • dry_run_invalid_mapping_reports_error--dry-run with bad mapping
  • no_mapping_flags_passthrough — Passthrough without mapping
  • full_integration_json_to_yaml_with_mapping — Full end-to-end with file I/O

Fixes #19

- Add -m/--mapping flag to load .morph mapping files
- Add -e/--expr flag for inline mapping expressions (repeatable)
- Add --dry-run flag to validate mappings without executing
- Multiple -e flags combine in order; -m and -e can combine (file first)
- No mapping flags = straight passthrough conversion
- Add 10 integration tests and 7 unit tests covering all TDD scenarios

Fixes #19
@alvinreal alvinreal merged commit 2a8100e into main Feb 21, 2026
6 checks passed
@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.

CLI: -m (mapping file) and -e (inline expression) flags

1 participant