type Engine … // NewEngine returns an Engine configured with a basic set of commands and conditions. func NewEngine() *Engine { … } type Cmd … type WaitFunc … type CmdUsage … type Cond … type CondUsage … // Execute reads and executes script, writing the output to log. // // Execute stops and returns an error at the first command that does not succeed. // The returned error's text begins with "file:line: ". // // If the script runs to completion or ends by a 'stop' command, // Execute returns nil. // // Execute does not stop background commands started by the script // before returning. To stop those, use [State.CloseAndWait] or the // [Wait] command. func (e *Engine) Execute(s *State, file string, script *bufio.Reader, log io.Writer) (err error) { … } type command … type expectedStatus … const success … const failure … const successOrFailure … type argFragment … type condition … const argSepChars … // parse parses a single line as a list of space-separated arguments. // subject to environment variable expansion (but not resplitting). // Single quotes around text disable splitting and expansion. // To embed a single quote, double it: // // 'Don''t communicate by sharing memory.' func parse(filename string, lineno int, line string) (cmd *command, err error) { … } // expandArgs expands the shell variables in rawArgs and joins them to form the // final arguments to pass to a command. func expandArgs(s *State, rawArgs [][]argFragment, regexpArgs []int) []string { … } // quoteArgs returns a string that parse would parse as args when passed to a command. // // TODO(bcmills): This function should have a fuzz test. func quoteArgs(args []string) string { … } func (e *Engine) conditionsActive(s *State, conds []condition) (bool, error) { … } func (e *Engine) runCommand(s *State, cmd *command, impl Cmd) error { … } func checkStatus(cmd *command, err error) error { … } // ListCmds prints to w a list of the named commands, // annotating each with its arguments and a short usage summary. // If verbose is true, ListCmds prints full details for each command. // // Each of the name arguments should be a command name. // If no names are passed as arguments, ListCmds lists all the // commands registered in e. func (e *Engine) ListCmds(w io.Writer, verbose bool, names ...string) error { … } func wrapLine(w io.Writer, line string, cols int, indent string) error { … } // ListConds prints to w a list of conditions, one per line, // annotating each with a description and whether the condition // is true in the state s (if s is non-nil). // // Each of the tag arguments should be a condition string of // the form "name" or "name:suffix". If no tags are passed as // arguments, ListConds lists all conditions registered in // the engine e. func (e *Engine) ListConds(w io.Writer, s *State, tags ...string) error { … }