spudplate
Template scaffolding compiler for spudlang .spud files
Loading...
Searching...
No Matches
spudplate::Prompter Class Referenceabstract

Abstract source of user input for ask statements. More...

#include <interpreter.h>

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

Public Member Functions

virtual std::string prompt (const PromptRequest &req)=0
 Display the prompt described by req and return the user's raw answer.
 
virtual bool authorize (const std::string &summary)=0
 Display a security summary and return whether to proceed.
 

Detailed Description

Abstract source of user input for ask statements.

Member Function Documentation

◆ prompt()

virtual std::string spudplate::Prompter::prompt ( const PromptRequest req)
pure virtual

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.

Implemented in spudplate::StdinPrompter, and spudplate::ScriptedPrompter.

◆ authorize()

virtual bool spudplate::Prompter::authorize ( const std::string &  summary)
pure virtual

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.

Implemented in spudplate::StdinPrompter, and spudplate::ScriptedPrompter.