spudplate
Template scaffolding compiler for spudlang .spud files
Loading...
Searching...
No Matches
spudplate::StdinPrompter Class Reference

Production prompter: writes to a stream and reads a line from another. More...

#include <interpreter.h>

Inheritance diagram for spudplate::StdinPrompter:
spudplate::Prompter

Public Member Functions

 StdinPrompter ()
 Default constructor: read from std::cin, write to std::cout, auto-detect colour support.
 
 StdinPrompter (std::istream &in, std::ostream &out, bool use_colour)
 Inject custom streams and explicit colour mode (test-only).
 
std::string prompt (const PromptRequest &req) override
 Display the prompt described by req and return the user's raw answer.
 
bool authorize (const std::string &summary) override
 Display a security summary and return whether to proceed.
 

Detailed Description

Production prompter: writes to a stream and reads a line from another.

Defaults to std::cin and std::cout with auto-detected colour support (suppressed when NO_COLOR is set or stdout is not a tty). The stream-injecting constructor exists for tests.

Member Function Documentation

◆ prompt()

std::string spudplate::StdinPrompter::prompt ( const PromptRequest req)
overridevirtual

Display the prompt described by req and return the user's raw answer.

The interpreter parses the returned string, validates it against type and options, and on rejection calls back with previous_error set. Implementations deliver one raw line per call.

Implements spudplate::Prompter.

◆ authorize()

bool spudplate::StdinPrompter::authorize ( const std::string &  summary)
overridevirtual

Display a security summary and return whether to proceed.

Called once, before any statement runs, when the program contains run clauses. The summary is multi-line and lists every literal command that may execute. Returning false aborts the run cleanly with no side effects.

Implements spudplate::Prompter.