Skip to content

Conversation

Copy link

Copilot AI commented Jul 8, 2025

This PR adds a quiet flag to dotenv-cli that suppresses debug output from the underlying dotenv library by default, addressing log spamming issues that can interfere with scripts that output to files.

Problem

Dotenv v17 introduces verbose debug logging that can spam output, making it problematic for scripts that need clean output or redirect to files. The issue requested that a quiet flag should be enabled by default in the CLI.

Solution

Added --quiet/-q and --verbose flags with the following behavior:

  • Default behavior: Quiet mode (no dotenv debug output)
  • --quiet or -q: Explicitly suppress debug output (redundant but available for clarity)
  • --verbose: Enable dotenv debug output when needed

Example Usage

# Default behavior - quiet (no debug output)
dotenv -- echo "hello"

# Explicit quiet mode
dotenv --quiet -- echo "hello" 
dotenv -q -- echo "hello"

# Verbose mode - shows dotenv debug messages
dotenv --verbose -- echo "hello"
# Output: [[email protected]][DEBUG] No encoding is specified. UTF-8 is used by default

Changes Made

  1. Added flag handling logic:

    const isQuiet = argv.quiet || argv.q || !argv.verbose
    const enableDotenvDebug = !isQuiet
  2. Updated dotenv.config() calls to respect the debug setting:

    dotenv.config({ path: path.resolve(env), override, debug: enableDotenvDebug })
  3. Updated help text to document the new flags and indicate quiet is the default

Backward Compatibility

  • All existing functionality works exactly as before
  • The existing --debug flag continues to work independently for CLI debug output (showing paths and variables)
  • No breaking changes to the API or command-line interface

Testing

Validated all scenarios including:

  • Default quiet behavior
  • Explicit quiet and verbose modes
  • Interaction with existing --debug flag
  • Flag combinations and edge cases
  • Error handling with appropriate verbosity levels

Fixes #1.


💡 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.

Copilot AI changed the title [WIP] Add quiet flag Add quiet flag to suppress dotenv debug output by default Jul 8, 2025
Copilot AI requested a review from villelahdenvuo July 8, 2025 05:45
Copilot finished work on behalf of villelahdenvuo July 8, 2025 05:45
@villelahdenvuo
Copy link
Member

  1. The issue says that the problem is with dotenv@17 latest version that enabled log messages by default and you did not update the dependencies first.
  2. You added an extra --verbose flag even though the CLI already has a --debug flag, no need for --verbose
  3. Just add --quiet that stops the new non-debug logs and make it true by default so that you can disable it via --quiet=false or -q false and test it using the latest dotenv version.

Copy link
Author

Copilot AI commented Jul 8, 2025

  1. The issue says that the problem is with dotenv@17 latest version that enabled log messages by default and you did not update the dependencies first.
  2. You added an extra --verbose flag even thoug...

Updated the implementation based on your feedback:

  1. ✅ Updated dotenv dependency to v17.1.0 to reproduce the verbose logging issue
  2. ✅ Removed the unnecessary --verbose flag (keeping only existing --debug for CLI debugging)
  3. ✅ Simplified to just --quiet flag that defaults to true and can be disabled with --quiet=false or -q=false

The implementation now uses dotenv's quiet option properly and maintains backward compatibility with all existing functionality. Fixed in commit 396f7e7.

Copilot finished work on behalf of villelahdenvuo July 8, 2025 05:59
@villelahdenvuo villelahdenvuo marked this pull request as ready for review July 8, 2025 06:00
@villelahdenvuo villelahdenvuo merged commit bd9cf2b into master Jul 8, 2025
@villelahdenvuo
Copy link
Member

@copilot const isQuiet = !(argv.quiet === false || argv.q === false || argv.quiet === 'false' || argv.q === 'false')

The flag should always be either string or boolean but not both? Which one is it? Remove the check for the unused type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Add quiet flag

2 participants