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
19 changes: 19 additions & 0 deletions src/cli/args/backend_arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,25 @@ impl BackendArg {
}
}

pub fn full_with_opts(&self) -> String {
let full = self.full();
if regex!(r"^(.+)\[(.+)\]$").is_match(&full) {
return full;
}
if let Some(opts) = &self.opts {
let opts_str = opts
.opts
.iter()
.map(|(k, v)| format!("{k}={v}"))
.collect::<Vec<_>>()
.join(",");
if !full.contains(['[', ']']) && !opts_str.is_empty() {
return format!("{full}[{opts_str}]");
}
}
full
}

pub fn opts(&self) -> ToolVersionOptions {
self.opts.clone().unwrap_or_else(|| {
if let Some(c) = regex!(r"^(.+)\[(.+)\]$").captures(&self.full()) {
Expand Down
7 changes: 6 additions & 1 deletion src/toolset/install_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,12 @@ fn read_backend_meta(short: &str) -> Option<Vec<String>> {
}

pub fn write_backend_meta(ba: &BackendArg) -> Result<()> {
let doc = format!("{}\n{}", ba.short, ba.full());
// do not write options for core plugins
let full = match ba.full().starts_with("core:") {
true => ba.full(),
false => ba.full_with_opts(),
};
let doc = format!("{}\n{}", ba.short, full);
file::write(backend_meta_path(&ba.short), doc.trim())?;
Ok(())
}
Expand Down