yash_cli::startup::input

Function prepare_input

source
pub fn prepare_input<'s: 'i + 'e, 'i, 'e>(
    env: &'i RefCell<&mut Env>,
    source: &'s Source,
) -> Result<SourceInput<'i>, PrepareInputError<'e>>
Expand description

Prepares the input for the shell.

This function constructs an input object from the given source with the following decorators:

  • If the source is read with a file descriptor, the Echo decorator is applied to the input to implement the Verbose shell option.
  • If the Interactive option is enabled and the source is read with a file descriptor, the Prompter decorator is applied to the input to show the prompt.
  • If the Interactive option is enabled, the Reporter decorator is applied to the input to show changes in job status before prompting for the next command.
  • If the Interactive option is enabled and the source is read with a file descriptor, the IgnoreEof decorator is applied to the input to implement the IgnoreEof shell option.

The RefCell passed as the first argument should be shared with (and only with) the read_eval_loop function that consumes the input and executes the parsed commands.