Skip to main content

try_recover_missing_args

Function try_recover_missing_args 

Source
pub fn try_recover_missing_args(
    err: &Error,
    original_args: &[String],
    command: &Command,
    app_name: &str,
    auto_interactive: bool,
) -> Option<RecoveryResult>
Expand description

Attempt to interactively recover from a clap MissingRequiredArgument error.

When the CLI is running interactively and clap reports missing required arguments, this function prompts the user for each missing value (in declaration order), appends them to the original args, and returns Some with the augmented arg list so the caller can re-parse.

Returns None if recovery is not possible (non-interactive or not a missing-arg error). Returns Some(RecoveryResult::Cancelled { .. }) if the user cancels mid-prompt.

§Arguments

  • err — the clap error from try_get_matches_from
  • original_args — the args that were passed to clap
  • command — the root clap::Command (for arg introspection)
  • app_name — the CLI binary name (first arg)
  • auto_interactive — whether the CLI opted into TTY auto-detection