Skip to content

Commit 487808f

Browse files
authored
Use preset path directly if it exists (#44)
* Use preset path directly if it exists * Update preset argument documentation
1 parent 685389f commit 487808f

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

xtasks/crates/config/src/main.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ struct Cli {
2323
enum Subcommand {
2424
/// Load a preset configuration.
2525
Load {
26-
/// Name of the preset to load. Must correspond to a file in the `presets/` directory without the `.toml` extension.
26+
/// Name of the preset to load. Can either be a path, or the name of a file in the `presets/` directory without the `.toml` extension.
2727
preset: String,
2828
/// Do not ask for confirmation.
2929
#[arg(long, default_value_t = false)]
@@ -79,8 +79,14 @@ fn ask_confirmation(prompt: &str) -> bool {
7979
}
8080

8181
fn run_load_preset(preset_name: &str, no_confirm: bool, current_dir: &Path) -> Result<(), Error> {
82-
// Load the preset file from the `presets/` directory.
83-
let preset_path = PathBuf::from("presets").join(format!("{preset_name}.toml"));
82+
// Load the file, or get it from the `presets/` directory
83+
let pb = PathBuf::from(preset_name);
84+
let preset_path = if pb.is_file() {
85+
pb
86+
} else {
87+
PathBuf::from("presets").join(format!("{preset_name}.toml"))
88+
};
89+
8490
let preset = config::load_toml(&preset_path)?;
8591

8692
let config_path = current_dir.join("config.toml");

0 commit comments

Comments
 (0)