Story
As an operator,
I want to pipe a plain-text input file to the CLI,
so that I can run a full mission without typing commands interactively.
Architecture Reference: 05-building-blocks.md — InputParser, __main__ adapter; 01-introduction.md — FR-1, FR-2, FR-3; 02-constraints.md — TC-3
Backend Sub-Story
Story ID: CLI-BE-001.1
As a developer I want an InputParser that converts raw stdin text into domain objects so that the domain layer never handles raw strings.
Architecture Reference: 05-building-blocks.md — InputParser; 04-solution-strategy.md — Hexagonal architecture (adapter layer); 11-risks-and-technical-debts.md — TD-4
Scenarios:
SCENARIO 1: Parser raises ValueError with descriptive message on bad plateau line
Scenario ID: CLI-BE-001.1-S1
GIVEN
WHEN
THEN
SCENARIO 2: Parser raises ValueError on invalid heading
Scenario ID: CLI-BE-001.1-S2
GIVEN
WHEN
THEN
Entry point — mars_rover/__main__.py
import sys
from mars_rover.adapters.input_parser import InputParser
from mars_rover.adapters.output_formatter import OutputFormatter
from mars_rover.application.mission_controller import MissionController
def main() -> None:
text = sys.stdin.read()
try:
parser = InputParser()
plateau, missions = parser.parse(text)
except ValueError as exc:
print(f"Input error: {exc}", file=sys.stderr)
sys.exit(1)
controller = MissionController(plateau)
rovers = controller.run(missions)
formatter = OutputFormatter()
for rover in rovers:
print(formatter.format(rover))
if __name__ == "__main__":
main()
Note: This entry point is the initial implementation. NAV-STORY-003 (obstacle detection) updates MissionController.run() to return list[tuple[Rover, bool]] and updates this loop accordingly — see obstacle-detection.md.
Frontend Sub-Story
Story ID: CLI-FE-001.1
As an operator I want to pipe a text file to the CLI so that I can run missions non-interactively from scripts or CI.
Architecture Reference: 03-context.md — Operator → System interface; 07-deployment.md — single-process CLI
Scenarios:
SCENARIO 1: Operator pipes a file to the CLI
Scenario ID: CLI-FE-001.1-S1
GIVEN
WHEN
THEN
# Pipe a file
python -m mars_rover < input.txt
# Inline heredoc
python -m mars_rover <<EOF
5 5
1 2 N
LMLMLMLMM
EOF
Infrastructure Sub-Story
Story ID: CLI-INFRA-001.1
As a developer I want the CLI input parsing functionality to be containerized and testable so that input validation works consistently across environments.
Architecture Reference: 07-deployment.md — deployment topology; 02-constraints.md — TC-1, TC-3