feat: add output flag #13

Merged
mvhutz merged 2 commits from feat/output-flag into main 2026-01-11 22:14:49 +00:00
Owner

Description

The lambda CLI previously only wrote output to stdout using shell redirection.
This PR adds support for writing results to files using the -o flag.
This is implemented using a new Destination interface that mirrors the existing Source pattern.

Changes:

  • Added Destination interface with StdoutDestination and FileDestination implementations.
  • Added -o flag to CLI argument parser for output file specification.
  • Updated Config to use Destination instead of direct output handling.
  • Refactored main to use Destination.Write() for result output.
  • Updated Makefile targets (run, profile, explain) to use -o flag instead of shell redirection.

Decisions

The -o flag defaults to stdout when not specified or when set to -.
This maintains backward compatibility while providing explicit file output capability.

Benefits

  • Cleaner command-line interface without shell redirection.
  • Symmetric design with Source interface for input.
  • More portable across different shells and environments.
  • Explicit output handling improves code clarity.

Checklist

  • Code follows conventional commit format.
  • Branch follows naming convention (<type>/<description>).
  • Tests pass (if applicable).
  • Documentation updated (if applicable).
## Description The lambda CLI previously only wrote output to stdout using shell redirection. This PR adds support for writing results to files using the `-o` flag. This is implemented using a new `Destination` interface that mirrors the existing `Source` pattern. Changes: - Added `Destination` interface with `StdoutDestination` and `FileDestination` implementations. - Added `-o` flag to CLI argument parser for output file specification. - Updated `Config` to use `Destination` instead of direct output handling. - Refactored main to use `Destination.Write()` for result output. - Updated Makefile targets (`run`, `profile`, `explain`) to use `-o` flag instead of shell redirection. ### Decisions The `-o` flag defaults to stdout when not specified or when set to `-`. This maintains backward compatibility while providing explicit file output capability. ## Benefits - Cleaner command-line interface without shell redirection. - Symmetric design with `Source` interface for input. - More portable across different shells and environments. - Explicit output handling improves code clarity. ## Checklist - [x] Code follows conventional commit format. - [x] Branch follows naming convention (`<type>/<description>`). - [ ] Tests pass (if applicable). - [ ] Documentation updated (if applicable).
mvhutz added 2 commits 2026-01-11 22:13:03 +00:00
Added -o flag to write results to files using a new Destination interface.

Changes:
- Add Destination interface with StdoutDestination and FileDestination implementations.
- Add -o flag to CLI parser for output file specification.
- Update Config to use Destination instead of direct output handling.
- Refactor main to use Destination.Write() for result output.
mvhutz merged commit 0eff85f8fa into main 2026-01-11 22:14:49 +00:00
mvhutz deleted branch feat/output-flag 2026-01-11 22:14:49 +00:00
mvhutz referenced this issue from a commit 2026-01-11 22:14:51 +00:00
Sign in to join this conversation.