mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-09-11 22:53:00 +00:00
simplify: add CommandContext::verbose() accessor
The check `ctx.user_settings().cli.output.verbosity == OutputVerbosity::Verbose` repeated 6 times across doctor, preflight, run command/resume/mod. Add a `verbose()` method and replace every call site. `cargo fix` handles the now-unused `OutputVerbosity` imports. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
829a02f1f8
commit
3bfd93aa60
6 changed files with 11 additions and 15 deletions
|
|
@ -5,7 +5,7 @@ use anyhow::{Context as _, Result, bail};
|
|||
use fabro_config::UserSettings;
|
||||
use fabro_config::merge::combine_files;
|
||||
use fabro_types::settings::SettingsLayer;
|
||||
use fabro_types::settings::cli::{CliLayer, OutputFormat};
|
||||
use fabro_types::settings::cli::{CliLayer, OutputFormat, OutputVerbosity};
|
||||
use fabro_util::printer::Printer;
|
||||
use tokio::sync::OnceCell;
|
||||
|
||||
|
|
@ -100,6 +100,10 @@ impl CommandContext {
|
|||
self.user_settings.cli.output.format == OutputFormat::Json
|
||||
}
|
||||
|
||||
pub(crate) fn verbose(&self) -> bool {
|
||||
self.user_settings.cli.output.verbosity == OutputVerbosity::Verbose
|
||||
}
|
||||
|
||||
pub(crate) async fn server(&self) -> Result<Arc<Client>> {
|
||||
let server_mode = self.server_mode.clone();
|
||||
let base_config_path = self.base_config_path.clone();
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ use std::path::PathBuf;
|
|||
use anyhow::Result;
|
||||
use fabro_api::types as api_types;
|
||||
use fabro_config::user::active_settings_path;
|
||||
use fabro_types::settings::cli::OutputVerbosity;
|
||||
pub(crate) use fabro_util::check_report::{
|
||||
CheckDetail, CheckReport, CheckResult, CheckSection, CheckStatus,
|
||||
};
|
||||
|
|
@ -143,8 +142,7 @@ pub(crate) async fn run_doctor(
|
|||
args: &DoctorArgs,
|
||||
base_ctx: &CommandContext,
|
||||
) -> Result<i32, anyhow::Error> {
|
||||
let verbose =
|
||||
args.verbose || base_ctx.user_settings().cli.output.verbosity == OutputVerbosity::Verbose;
|
||||
let verbose = args.verbose || base_ctx.verbose();
|
||||
let printer = base_ctx.printer();
|
||||
let styles = Styles::detect_stdout();
|
||||
let json = base_ctx.json_output();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
use anyhow::bail;
|
||||
use fabro_config::load::load_settings_user;
|
||||
use fabro_config::user::active_settings_path;
|
||||
use fabro_types::settings::cli::OutputVerbosity;
|
||||
use fabro_util::terminal::Styles;
|
||||
|
||||
use crate::args::PreflightArgs;
|
||||
|
|
@ -20,8 +19,7 @@ pub(crate) async fn execute(
|
|||
let styles: &'static Styles = Box::leak(Box::new(Styles::detect_stderr()));
|
||||
let printer = base_ctx.printer();
|
||||
let ctx = base_ctx.with_target(&args.target)?;
|
||||
args.verbose =
|
||||
args.verbose || ctx.user_settings().cli.output.verbosity == OutputVerbosity::Verbose;
|
||||
args.verbose = args.verbose || ctx.verbose();
|
||||
|
||||
let manifest = build_run_manifest(ManifestBuildInput {
|
||||
workflow: args.workflow.clone(),
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
use anyhow::Result;
|
||||
use fabro_types::settings::cli::OutputVerbosity;
|
||||
use fabro_util::terminal::Styles;
|
||||
|
||||
use crate::args::RunArgs;
|
||||
|
|
@ -10,8 +9,7 @@ pub(crate) async fn execute(mut args: RunArgs, base_ctx: &CommandContext) -> Res
|
|||
let styles: &'static Styles = Box::leak(Box::new(Styles::detect_stderr()));
|
||||
let printer = base_ctx.printer();
|
||||
let ctx = base_ctx.with_target(&args.target)?;
|
||||
args.verbose =
|
||||
args.verbose || ctx.user_settings().cli.output.verbosity == OutputVerbosity::Verbose;
|
||||
args.verbose = args.verbose || ctx.verbose();
|
||||
|
||||
let quiet = args.detach;
|
||||
let prevent_idle_sleep = ctx.user_settings().cli.exec.prevent_idle_sleep;
|
||||
|
|
@ -49,7 +47,7 @@ pub(crate) async fn execute(mut args: RunArgs, base_ctx: &CommandContext) -> Res
|
|||
true,
|
||||
styles,
|
||||
json,
|
||||
ctx.user_settings().cli.output.verbosity == OutputVerbosity::Verbose,
|
||||
ctx.verbose(),
|
||||
printer,
|
||||
))
|
||||
.await?;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
use anyhow::Result;
|
||||
use fabro_types::settings::cli::OutputVerbosity;
|
||||
use fabro_util::terminal::Styles;
|
||||
|
||||
use crate::args::{AttachArgs, RunCommands, RunWorkerArgs, StartArgs};
|
||||
|
|
@ -62,7 +61,7 @@ pub(crate) async fn dispatch(cmd: RunCommands, base_ctx: &CommandContext) -> Res
|
|||
false,
|
||||
styles,
|
||||
json,
|
||||
ctx.user_settings().cli.output.verbosity == OutputVerbosity::Verbose,
|
||||
ctx.verbose(),
|
||||
printer,
|
||||
))
|
||||
.await?;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
use fabro_types::settings::cli::OutputVerbosity;
|
||||
use fabro_util::terminal::Styles;
|
||||
|
||||
use crate::args::ResumeArgs;
|
||||
|
|
@ -36,7 +35,7 @@ pub(crate) async fn resume_command(
|
|||
true,
|
||||
styles,
|
||||
json,
|
||||
ctx.user_settings().cli.output.verbosity == OutputVerbosity::Verbose,
|
||||
ctx.verbose(),
|
||||
printer,
|
||||
))
|
||||
.await?;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue