Skip to content

Add global --quiet flag for script-friendly stderr suppression #1805

Description

@Widthdom

Summary

cdidx has no --quiet / --silent flag. Query commands write informational messages to stderr ("No results found.", file counts, progress hints) unconditionally, even from inside shell scripts that just want the JSON or a non-zero exit code. Users either redirect stderr to /dev/null (losing genuine errors) or accept noisy pipelines. There is no canonical way to ask cdidx to "shut up unless something is wrong".

Where

  • src/CodeIndex/Cli/ConsoleUi.cs:13-40 (no --quiet in usage)
  • Information emission scattered across QueryCommandRunner.cs

Suggested approach

(1) Add a global --quiet / -q flag (and CDIDX_QUIET=1 env) that suppresses all stderr output except LogLevel >= Error. (2) Add a --silent alias for symmetry with curl/wget — same behavior. (3) Wrap every informational stderr write behind a ConsoleUi.WriteInfo(...) helper that short-circuits when quiet mode is set. (4) Keep the spinner / progress bar visible when stdout is a TTY but suppress when --quiet is set. (5) Document the precedence: --quiet overrides --verbose; both can coexist for "errors-only with file/line context". (6) Add a regression test that runs cdidx --quiet search nonexistent and asserts zero stderr bytes plus non-zero exit. (7) Document under "Output verbosity controls".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions