Skip to content

Conversation

sarataha
Copy link

@sarataha sarataha commented Sep 1, 2025

Description of change

Add -q/--quiet flag to cargo shuttle run to suppress non-error output.

Closes #1602

How has this been tested? (if applicable)

Verified flag appears in help output and tested flag parsing and behavior logic.

Add -q/--quiet flag to suppress non-error output.

Closes shuttle-hq#1602
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Summary

This PR adds a --quiet flag (-q/--quiet) to the cargo shuttle run command, implementing functionality to suppress non-error output during local development runs. The implementation follows a clean three-part approach:

  1. Argument Definition: A new quiet boolean field is added to the RunArgs struct in args.rs, following the established clap attribute pattern with both short (-q) and long (--quiet) forms.

  2. Output Suppression: The main functionality in lib.rs wraps build status messages and service startup messages in conditional checks based on run_args.quiet. When the flag is enabled, these informational messages are suppressed while error output remains visible.

  3. Logging Configuration: An intelligent logging override sets RUST_LOG="info,shuttle=error" when quiet mode is active and no custom RUST_LOG is already set. This ensures that shuttle-specific logs are reduced to errors only while preserving info-level logs from other components.

The change integrates seamlessly with the existing CLI infrastructure and follows the established patterns in the codebase. The integration test was updated to explicitly set quiet: false to maintain existing test behavior, ensuring verbose output remains available for debugging test failures.

Important Files Changed

Files Modified
Filename Score Overview
cargo-shuttle/src/args.rs 5/5 Added quiet boolean field to RunArgs struct with proper clap attributes
cargo-shuttle/src/lib.rs 5/5 Implemented conditional output suppression and intelligent RUST_LOG override for quiet mode
cargo-shuttle/tests/integration/run.rs 5/5 Updated test to explicitly set quiet: false to maintain existing test behavior

Confidence score: 4/5

  • This PR is safe to merge with minimal risk as it adds optional functionality without breaking existing behavior
  • Score reflects well-structured implementation following established patterns, but lacks comprehensive testing of the new quiet functionality
  • Pay close attention to cargo-shuttle/src/lib.rs to ensure the logging override logic works correctly in different environments

Sequence Diagram

sequenceDiagram
    participant User
    participant CLI as "cargo-shuttle CLI"
    participant Shuttle as "Shuttle::local_run"
    participant Builder as "build_workspace"
    participant Runtime as "Runtime Process"

    User->>CLI: "cargo shuttle run --quiet"
    CLI->>CLI: "Parse args with quiet=true"
    CLI->>Shuttle: "local_run(run_args, debug)"
    
    alt if not bacon mode
        Shuttle->>Shuttle: "pre_local_run(run_args)"
        
        alt if not quiet
            Shuttle->>User: "Building {project_directory}"
        end
        
        Shuttle->>Builder: "build_workspace(project_directory, release, tx)"
        Builder->>Shuttle: "BuiltService"
        
        Shuttle->>Shuttle: "find_available_port(run_args)"
        
        alt if not quiet
            Shuttle->>User: "Starting {service} on http://{ip}:{port}"
        end
        
        alt if quiet and no RUST_LOG set
            Shuttle->>Runtime: "Set RUST_LOG=info,shuttle=error"
        end
        
        Shuttle->>Runtime: "spawn runtime process"
        Runtime->>User: "Application logs (if any errors)"
    else bacon mode
        Shuttle->>User: "Starting {project} in watch mode using bacon"
        Shuttle->>Runtime: "run_bacon(project_directory)"
    end
Loading

3 files reviewed, no comments

Edit Code Review Bot Settings | Greptile

@jonaro00
Copy link
Member

jonaro00 commented Sep 9, 2025

Thanks for the PR! There are some conflicts with the main branch now. After that is resolved, we also want to pass the --quiet flag to any cargo or docker subprocesses we launch as part of building ahead of the local run.
Later, this can evolve into a global flag that is the opposite to --debug :)

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.

[Improvement]: --quiet flag for local runs
2 participants