Skip to content

Commit

Permalink
--config-toml argument
Browse files Browse the repository at this point in the history
Fix #284
  • Loading branch information
Canop committed Jan 11, 2025
1 parent 11c7ea6 commit 54aaf7b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/conf/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ pub struct Args {
#[clap(long, value_name = "project")]
pub project: Option<String>,

/// Configuration passed as a TOML string
#[clap(long)]
pub config_toml: Option<String>,

#[clap()]
/// What to do: either a job, or a path, or both
pub args: Vec<String>,
Expand Down
7 changes: 7 additions & 0 deletions src/conf/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ impl Settings {
/// * the package level `bacon.toml` file in package-root/.bacon.toml
/// * the package level `bacon.toml` file in package-root/.config/.bacon.toml
/// * the file whose path is in environment variable `BACON_CONFIG`
/// * the content of the `--config-toml` argument
/// * args given as arguments, coming from the cli call
pub fn read(
args: &Args,
Expand Down Expand Up @@ -122,6 +123,12 @@ impl Settings {
}
}

if let Some(toml) = &args.config_toml {
let config = toml::from_str(toml)?;
info!("config loaded from --config-toml: {:#?}", &config);
settings.apply_config(&config);
}

settings.apply_args(args);
settings.check()?;
info!("settings: {:#?}", &settings);
Expand Down

0 comments on commit 54aaf7b

Please sign in to comment.