Skip to main content

Module repl

Module repl 

Source
Expand description

Interactive prompt, used when hashiverse-cli is run without a command.

Each line is split into words (see split_repl_words) and is either a REPL-only command (help, quit/exit, login <client_id_hex>) or one of the regular Commands, parsed by the same clap definitions as the one-shot CLI. The identity and network connection persist across lines, so repeating user X / hashtag Y walks further back in that timeline.

The loop is generic over ReplSession so it can be tested without a network.

Structs§

LiveReplSession

Enums§

ReplLine

Traits§

ReplSession
The state the REPL drives: the current identity and how to run commands against it.

Functions§

format_prompt
help_text
The list shown by help, built from the clap definitions so it never drifts from them.
parse_repl_line
Parses one line. Err carries a message ready to show the user (including clap’s usage text, or a command’s --help output).
run_repl
Runs the prompt loop until quit/exit or end of input. Command output goes to output, errors to error_output; a failing line never ends the loop. In a --json session (session_json) prompts, help and login status also go to error_output, keeping output JSON-only. A per-line --json only changes that command’s output.
split_repl_words
Splits a line into words, shell-style: whitespace separates words, "..." and '...' group them, and a backslash escapes the next character (outside single quotes). Unlike a real shell there is no comment syntax, so #hashtag is an ordinary word.