Skip to content

Add --silent flag to suppress non-error output#12

Merged
fbosch merged 2 commits into
masterfrom
copilot/add-silent-flag-to-commands
Feb 2, 2026
Merged

Add --silent flag to suppress non-error output#12
fbosch merged 2 commits into
masterfrom
copilot/add-silent-flag-to-commands

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 2, 2026

Adds --silent flag to suppress informational output while preserving error messages on stderr.

Implementation

  • UI module (src/cli/ui.ts): Introduced module-level _silentMode flag checked by all output functions (line, header, item, step)
  • Option plumbing: Added silent: boolean to CliOptions, parsed in parse-args.ts, activated early in main() via setSilentMode()
  • Output behavior: --json output unaffected by --silent (explicit structured output request honored)

Usage

# Suppress all output except errors
docs-cache sync --silent

# Still get JSON even with --silent
docs-cache status --json --silent

# Errors always shown regardless of --silent
docs-cache remove nonexistent --silent
# ✖ No matching sources found to remove.
Original prompt

Create a --silent flag for the commands, still output errors


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added --silent CLI flag to suppress output when running commands.
  • Tests

    • Added test coverage for the silent mode functionality.

Co-authored-by: fbosch <6979916+fbosch@users.noreply.github.com>
Copilot AI changed the title [WIP] Add silent flag to commands while retaining error output Add --silent flag to suppress non-error output Feb 2, 2026
Copilot AI requested a review from fbosch February 2, 2026 07:36
@fbosch fbosch marked this pull request as ready for review February 2, 2026 08:20
Copilot AI review requested due to automatic review settings February 2, 2026 08:20
@fbosch
Copy link
Copy Markdown
Owner

fbosch commented Feb 2, 2026

@coderabbitai full review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 2, 2026

📝 Walkthrough

Walkthrough

The pull request introduces a new --silent CLI flag that suppresses UI output. The flag is parsed from command-line arguments, threaded through the options object, and used to activate silent mode in the UI module, causing output functions to conditionally skip printing.

Changes

Cohort / File(s) Summary
CLI Type & Parsing
src/cli/types.ts, src/cli/parse-args.ts
Added silent: boolean field to CliOptions interface. Parser now extracts and propagates the --silent flag from CLI arguments.
UI Silent Mode Implementation
src/cli/ui.ts, src/cli/index.ts
Implemented silent mode mechanism with private _silentMode flag and setSilentMode(silent: boolean) export. Output functions (line, header, item, step) now return early when silent mode is active. Main CLI entry point invokes setter when flag is present.
Tests
tests/cli-parse.test.js
Added two test cases verifying --silent flag is correctly parsed as true when provided and defaults to false when absent.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 With a whisper and hop through the code I do roam,
A --silent flag brings hush to the home,
The UI takes a vow of quiet so deep,
While data flows gently where echoes don't peep! 🤫✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a --silent flag to suppress non-error output, which aligns with all file changes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch copilot/add-silent-flag-to-commands

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 2, 2026

✅ Actions performed

Full review triggered.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Feb 2, 2026

Open in StackBlitz

npx https://pkg.pr.new/fbosch/docs-cache@12

commit: 8e8bade

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a --silent flag to the CLI to suppress non-error, human-oriented output while keeping JSON output and error messages unchanged.

Changes:

  • Extended CLI parsing and options (CliOptions, parseArgs) to support a silent: boolean flag, with tests verifying parsing and default behavior.
  • Introduced a module-level silent mode toggle in src/cli/ui.ts and wired all UI components (line, header, item, step) to respect it.
  • Updated the main CLI entrypoint to expose --silent in help text and activate silent mode early in main(), while leaving --json and stderr error output unaffected.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/cli-parse.test.js Adds tests ensuring parseArgs correctly parses --silent and defaults silent to false when absent.
src/cli/ui.ts Introduces _silentMode and setSilentMode, and gates all user-facing UI helpers on the silent flag.
src/cli/types.ts Extends CliOptions with a non-optional silent: boolean flag.
src/cli/parse-args.ts Registers the --silent CLI option and plumbs it into CliOptions.silent.
src/cli/index.ts Documents --silent in help, calls setSilentMode(parsed.options.silent) early in main(), and leaves JSON and error output behavior unchanged.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@fbosch fbosch merged commit d9cf4e0 into master Feb 2, 2026
13 checks passed
@fbosch fbosch deleted the copilot/add-silent-flag-to-commands branch February 2, 2026 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants