Ability to pipe stdin to the non-interactive cli mode #30
Labels
No labels
blocked
duplicate
needs
approval
needs
criteria
needs
estimate
needs
tests
question
step
doing
step
review
step
testing
step
todo
step
uat
type
admin
type
alert
type
bug
type
change
type
defect
type
dependencies
type
epic
type
idea
type
incident
type
investigation
type
spike
type
story
won't fix
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
RabbitLabs/calculator#30
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Milestone: 0.3.0
Story Points: 5
AS a user scripting calculator evaluations
I WANT to pipe expressions into the CLI non-interactive mode
SO THAT I can batch-evaluate expressions from a file or shell pipeline without entering interactive mode
Acceptance Criteria
GIVEN I run
calculator cliwith no expression argumentWHEN stdin is not a TTY (e.g.
echo "2 + 3" | calculator cliorcalculator cli < expressions.txt)THEN the CLI reads from stdin until EOF instead of showing the interactive prompt/banner
GIVEN stdin is piped or redirected into
calculator cliWHEN each non-empty line contains a valid expression
THEN the numeric result is printed to stdout (result only — no
=prefix, matchingcalculator cli "expr"output)AND each result is on its own line
GIVEN stdin contains multiple non-empty lines
WHEN I pipe them into
calculator cliTHEN each line is evaluated independently in order
AND I receive one result line per valid expression
GIVEN a piped/redirected line is empty or whitespace-only
WHEN the CLI processes stdin
THEN the line is skipped (no output, no error)
GIVEN a piped/redirected line contains an invalid expression
WHEN the CLI evaluates that line
THEN a clear error message is printed to stderr
AND processing continues for subsequent lines
AND the process exits with a non-zero exit code after all input is consumed if any line failed
GIVEN I run
calculator cli "2 + 3"with an expression argumentWHEN stdin may or may not be piped
THEN behaviour is unchanged from today (single-expression mode; argument takes precedence)
GIVEN I run
calculator cliwith stdin attached to a TTY (interactive terminal)WHEN no expression argument is provided
THEN the existing interactive REPL mode is unchanged (banner,
>prompt,quit/exit)Subtasks
calculator cli "expr"are unaffected (regression)Notes
src/cli.rsondevelop/release/0.1.0):calculator cli "expr"— single expression, prints resultcalculator cli— interactive REPL with promptsFleshed out acceptance criteria for piping stdin into the CLI non-interactive mode.
Key points:
calculator cliis run without an expression argument and stdin is not a TTY (piped or redirected), read expressions from stdin until EOF instead of entering interactive modecalculator cliwith a terminal) and single-expression mode (calculator cli "2 + 3") remain unchangedCriteria are specific enough to estimate. Moving to
needs/estimate.Story point estimate: 5
CLI stdin batch mode. Criteria are specific enough to size.
cli.rsis_terminal()branchingReference: focused CLI change in a single module (
src/cli.rs); no GUI work. Interactive TTY mode andcalculator cli "expr"are regression-only.Moving to
needs/tests.QA Testing Scripts
Story: Ability to pipe stdin to the non-interactive CLI mode
Estimate: 5 story points
TC-01 — Single expression via pipe (non-TTY stdin)
$PATHecho "2 + 3" | calculator cli5is printed to stdout (result only — no=prefix)TC-02 — Single expression via stdin redirect (non-TTY stdin)
expressions.txtcontaining10 - 4calculator cli < expressions.txt6is printed to stdoutTC-03 — Multiple valid lines, one result per line
calculator cliTC-04 — Empty and whitespace-only lines are skipped
calculator cliTC-05 — Invalid line: error to stderr, processing continues
calculator cliTC-06 — All lines invalid: non-zero exit, no stdout results
5 + *and10 / 0)calculator cliTC-07 — Single-expression mode unchanged when argument provided
echo "99 + 1" | calculator cli "2 + 3"5is printed to stdout (argument takes precedence; piped stdin is ignored)TC-08 — Interactive TTY mode unchanged (regression)
calculator cliwith stdin attached to a TTY and no expression argument>prompt are shown2 + 3prints5quitorexitends the session normallyTC-09 — Piped output format matches existing single-expression CLI
calculator cli "2 + 3"and separatelyecho "2 + 3" | calculator cli5only, same formatting)TC-10 — Multi-operation expressions follow engine rules in piped mode
echo "5 + 2 * 6" | calculator cli42is printed to stdout (same result ascalculator cli "5 + 2 * 6")TC-11 — Automated tests cover piped stdin scenarios
calculator cli "expr"modeTC-12 — GUI mode unaffected (regression)
Criteria are specific enough to test. Moving to
needs/approvalfor human sign-off before implementation.