Reuse one CLI config layer during run creation

This commit is contained in:
Bryan Helmkamp 2026-03-29 14:16:51 -04:00
parent ed651dcd57
commit c58ed933bf
No known key found for this signature in database
3 changed files with 8 additions and 4 deletions

View file

@ -6,12 +6,13 @@ use crate::args::{GlobalArgs, RunArgs};
pub(crate) async fn execute(mut args: RunArgs, _globals: &GlobalArgs) -> Result<()> {
let styles: &'static Styles = Box::leak(Box::new(Styles::detect_stderr()));
let cli_settings = ConfigLayer::cli()?.resolve()?;
let cli = ConfigLayer::cli()?;
let cli_settings = cli.clone().resolve()?;
args.verbose = args.verbose || cli_settings.verbose_enabled();
let quiet = args.detach;
let prevent_idle_sleep = cli_settings.prevent_idle_sleep_enabled();
let (run_id, run_dir) = super::create::create_run(&args, styles, quiet)?;
let (run_id, run_dir) = super::create::create_run(&args, cli, styles, quiet)?;
#[cfg(feature = "sleep_inhibitor")]
let _sleep_guard = crate::sleep_inhibitor::guard(prevent_idle_sleep);

View file

@ -13,6 +13,7 @@ use super::output::{print_diagnostics_from_error, print_workflow_report_from_per
/// This does NOT execute the workflow — it only prepares the run directory.
pub(crate) fn create_run(
args: &RunArgs,
cli_defaults: ConfigLayer,
styles: &Styles,
quiet: bool,
) -> anyhow::Result<(String, PathBuf)> {
@ -24,7 +25,7 @@ pub(crate) fn create_run(
let cwd = std::env::current_dir().unwrap_or_else(|_| PathBuf::from("."));
let settings: FabroSettings = cli_args_config
.combine(ConfigLayer::for_workflow(workflow_path, &cwd)?)
.combine(ConfigLayer::cli()?)
.combine(cli_defaults)
.resolve()?;
let created = match create(CreateRunInput {

View file

@ -1,4 +1,5 @@
use anyhow::Result;
use fabro_config::ConfigLayer;
use fabro_config::FabroSettingsExt;
use fabro_util::terminal::Styles;
use fabro_workflows::run_lookup::{resolve_run_combined, runs_base};
@ -34,7 +35,8 @@ pub(crate) async fn dispatch(cmd: RunCommands, globals: &GlobalArgs) -> Result<(
RunCommands::Run(args) => command::execute(args, globals).await,
RunCommands::Create(args) => {
let styles: &'static Styles = Box::leak(Box::new(Styles::detect_stderr()));
let (run_id, _run_dir) = create::create_run(&args, styles, true)?;
let cli = ConfigLayer::cli()?;
let (run_id, _run_dir) = create::create_run(&args, cli, styles, true)?;
println!("{run_id}");
Ok(())
}