Ability to save interactive session to a text file #31
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#31
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 in the calculator CLI interactive REPL
I WANT to save my session transcript to a text file
SO THAT I can keep a record of the expressions I evaluated and their results
Acceptance Criteria
GIVEN I run
calculator cliwith stdin attached to a TTY (interactive REPL mode)WHEN I evaluate one or more expressions during the session
THEN the CLI maintains an in-memory transcript of each non-empty expression entered (excluding REPL control commands)
GIVEN I am in an interactive REPL session with transcript entries
WHEN I enter the command
saveTHEN the transcript is written to
calculator-session.txtin the current working directoryAND a confirmation message is printed (e.g.
Session saved to calculator-session.txt)AND the REPL continues (I am not logged out)
GIVEN I am in an interactive REPL session with transcript entries
WHEN I enter the command
save <path>(e.g.save /tmp/my-session.txtorsave notes/calc.log)THEN the transcript is written to the specified file path
AND parent directories are created if they do not exist
AND a confirmation message is printed with the resolved path
AND the REPL continues
GIVEN a transcript entry was evaluated successfully
WHEN the session file is written
THEN the entry appears as one line:
{expression} = {result}(matching the numeric result shown in the REPL)GIVEN a transcript entry failed evaluation
WHEN the session file is written
THEN the entry appears as one line:
{expression} -> ERROR: {message}GIVEN I run
saveorsave <path>when the transcript is empty (no expressions evaluated yet)WHEN the command is processed
THEN a clear message is shown that there is nothing to save
AND no file is created (or an existing target file is not truncated)
GIVEN the target file already exists
WHEN I run
saveorsave <path>THEN the file is overwritten with the current transcript (no interactive overwrite prompt)
GIVEN I enter REPL control commands (
quit,exit,save,save <path>)WHEN the CLI processes them
THEN they are not added to the transcript and are not evaluated as expressions
GIVEN I run
calculator cli "2 + 3"(single-expression mode)WHEN stdin may or may not be piped
THEN behaviour is unchanged — this story does not add session saving to single-expression mode
GIVEN I run
calculator cliwith stdin that is not a TTY (piped/redirected batch mode from #30)WHEN expressions are read from stdin
THEN behaviour is unchanged — this story does not write session logs in batch mode
GIVEN I run
calculator cliinteractively as todayWHEN I enter expressions, empty lines,
quit, orexitTHEN existing interactive behaviour is unchanged aside from the new
savecommandsSubtasks
saveandsave <path>REPL commands (path parsing, directory creation, overwrite)savecommandsNotes
src/cli.rsonrelease/0.1.0): banner,>prompt, prints= {result}on success, errors to stderr,quit/exitto endcalculator-session.txtis a convention; override withsave <path>Fleshed out acceptance criteria for saving an interactive CLI session to a text file.
Key points:
save(default filecalculator-session.txtin cwd) andsave <path>(user-specified path), matching existingquit/exitcommand style{expression} = {result}(successful) or{expression} -> ERROR: {message}(failed)savedoes not exit the session; user can continue calculating and save again (overwrites the target file)calculator cli "expr") and piped stdin batch mode (#30) remain unchangedCriteria are specific enough to estimate. Moving to
needs/estimate.Story point estimate for saving an interactive CLI session to a text file.
Acceptance criteria are specific enough to size. Breakdown:
save/save <path>alongsidequit/exit)Comparable scope to #30 (piped stdin batch mode, also estimated at 5). GUI, single-expression mode, and piped batch mode remain explicitly out of scope.
Setting Story Points: 5 on the issue body. Moving to
needs/tests.QA Testing Scripts
Story: Ability to save interactive session to a text file
Estimate: 5 story points
TC-01 — Transcript accumulates during interactive REPL session
calculator cliwith stdin attached to a TTY (interactive REPL mode)2 + 3and then10 / 2save)TC-02 — Default
savewritescalculator-session.txtin cwdsavecalculator-session.txtis created in the current working directorySession saved to calculator-session.txt)TC-03 —
save <path>writes to a user-specified filesave /tmp/my-session.txt(orsave notes/calc.log)TC-04 —
save <path>creates parent directories if missingnotes/sessions/does not existsave notes/sessions/test.lognotes/sessions/test.logTC-05 — Successful evaluation line format in saved file
2 + 3(which prints= 5in the REPL) and then runsavecalculator-session.txtcontains a line:2 + 3 = 5TC-06 — Failed evaluation line format in saved file
5 + *) and then runsave5 + * -> ERROR: {message}{message}matches the error shown in the REPL/stderrTC-07 — Empty transcript: clear message, no file created
savecalculator-session.txtis not createdTC-08 — Empty transcript: existing target file is not truncated
calculator-session.txtalready exists with contentprevious sessionsaveprevious session(not truncated)TC-09 — Overwrite existing file without interactive prompt
calculator-session.txtalready exists with old contentsaveTC-10 — REPL control commands are excluded from transcript
2 + 2, then entersave, thenquit2 + 2 = 4save,save calculator-session.txt,quit, andexitdo not appear as transcript entriesTC-11 —
savedoes not evaluate as an expressionsave(with or without prior expressions)saveas a mathematical expressionsavecommand itselfTC-12 — Multiple saves during one session (overwrite on each save)
1 + 1, runsave, then evaluate3 + 3, and runsaveagaincalculator-session.txtcontains both lines after the second saveTC-13 — Single-expression mode unchanged (regression)
calculator cli "2 + 3"5is printed to stdout (result only)TC-14 — Piped stdin batch mode unchanged (regression, #30)
echo "2 + 3" | calculator cli(non-TTY stdin, no expression argument)5is printed to stdoutTC-15 — Existing interactive REPL behaviour unchanged (regression)
calculator cliwith stdin attached to a TTY>prompt are shown2 + 3prints= 5(or equivalent existing format)quitorexitends the session normallyTC-16 — CLI help text documents
savecommandssaveandsave <path>are documented alongsidequit/exitTC-17 — Automated tests cover save scenarios
TC-18 — GUI mode unaffected (regression)
Criteria are specific enough to test. Moving to
needs/approvalfor human sign-off before implementation.