Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 120 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ comfy-table = "7.1"
futures = "0.3"
rpassword = "7.4"
thiserror = "2"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] }
8 changes: 8 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ pub struct Cli {
#[arg(long, global = true)]
pub json: bool,

/// Show config-source details and enable debug logging.
#[arg(long, global = true, conflicts_with = "quiet", help_heading = "Global Options")]
pub verbose: bool,

/// Reduce logging to errors only.
#[arg(long, global = true, conflicts_with = "verbose", help_heading = "Global Options")]
pub quiet: bool,

#[command(subcommand)]
pub command: Command,
}
Expand Down
18 changes: 18 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mod output;
use std::process::ExitCode;

use clap::Parser;
use tracing_subscriber::EnvFilter;

use crate::cli::{Cli, Command, CommentCommand, IssueCommand};
use crate::error::CliResult;
Expand All @@ -16,6 +17,7 @@ use crate::output::OutputMode;
#[tokio::main]
async fn main() -> ExitCode {
let cli = Cli::parse();
init_tracing(cli.verbose, cli.quiet);
match run(cli).await {
Ok(()) => ExitCode::SUCCESS,
Err(err) => {
Expand Down Expand Up @@ -71,3 +73,19 @@ async fn run(cli: Cli) -> CliResult<()> {
},
}
}

fn init_tracing(verbose: bool, quiet: bool) {
let level = if quiet {
"error"
} else if verbose {
"debug"
} else {
"warn"
};

let _ = tracing_subscriber::fmt()
.with_target(false)
.without_time()
.with_env_filter(EnvFilter::new(level))
.try_init();
}
Loading