pemistahl/grex · error

error: no valid input could be found whatsoever

Error message

error: no valid input could be found whatsoever

What it means

The CLI's obtain_input returns Err(ErrorKind::InvalidInput, "error: no valid input could be found whatsoever") when neither stdin piped input nor a file path argument could supply test cases. Without any input, main aborts with this message instead of building a regex. It is a CLI-level input-resolution failure, not a library panic.

Solutions

  1. Pipe test cases in via stdin: `cat examples.txt | regexpbuilder`
  2. Pass the path to a file of test cases as the argument: `regexpbuilder examples.txt`
  3. Fix the calling script so it always redirects stdin or supplies a file argument; add an argument-presence check before invoking the binary

Example fix

// before (shell)
regexpbuilder
// after (shell)
cat examples.txt | regexpbuilder
# or
regexpbuilder examples.txt
Defensive patterns

Strategy: validation

Validate before calling

let has_stdin = !atty::is(atty::Stream::Stdin);
let has_file = std::env::args().nth(1).is_some();
if !has_stdin && !has_file { eprintln!("usage: regexpbuilder [file] (or pipe test cases on stdin)"); std::process::exit(2); }

Try / catch

match obtain_input() {
    Ok(cases) => build_regex(cases),
    Err(e) => { eprintln!("{}", e); std::process::exit(2); },
}

Prevention

When it happens

Trigger: Running the binary with no piped stdin and no file path argument; stdin is a TTY (interactive terminal) so no piped data exists; the code path checks both sources and finds neither usable.

Common situations: Running `regexpbuilder` bare in a terminal instead of piping examples into it; a script's pipe upstream produced nothing so stdin appears empty/unavailable; forgetting the file argument in a CI job.

Understand the failure class

Background: "no subcommand specified" and "... is required": CLI errors when a required argument is missing — this error's family across 13 libraries.


AI-assisted analysis of pemistahl/grex@99cc347707 (2026-09-13). Data as JSON: /api/errors/e3eb5d0efee650cc. Report an issue: GitHub.

Appendix: source

Thrown at src/main.rs:323

                    .collect_vec())
            } else {
                Ok(cli.input.clone())
            }
        } else if let Some(file_path) = &cli.file_path {
            let is_hyphen = file_path.as_os_str() == "-";
            let path = if is_hyphen && is_stdin_available {
                let mut stdin_file_path = String::new();
                stdin().read_to_string(&mut stdin_file_path)?;
                PathBuf::from(stdin_file_path.trim())
            } else {
                file_path.to_path_buf()
            };
            match std::fs::read_to_string(path) {
                Ok(file_content) => Ok(file_content.lines().map(|it| it.to_string()).collect_vec()),
                Err(error) => Err(error),
            }
        } else {
            Err(Error::new(
                ErrorKind::InvalidInput,
                "error: no valid input could be found whatsoever",
            ))
        }
    }

    pub(crate) fn handle_input(
        cli: &Cli,
        input: Result<Vec<String>, Error>,
    ) -> Result<(), Box<dyn std::error::Error>> {
        match input {
            Ok(test_cases) => {
                let mut builder = RegExpBuilder::from(&test_cases);

                if cli.is_digit_converted {
                    builder.with_conversion_of_digits();
                }

View on GitHub (pinned to 99cc347707)