Skip to content

Commit

Permalink
fix: Look for -P or --profile to get mise environment. (#2566)
Browse files Browse the repository at this point in the history
The long or short arg reported by clap does not include the
leading hyphens required when parsing.
  • Loading branch information
fiadliel committed Sep 12, 2024
1 parent 16cccdd commit 32956cb
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,15 +371,12 @@ fn prefer_stale(args: &[String]) -> bool {
}

fn environment(args: &[String]) -> Option<String> {
let long_arg = format!("--{}", ProfileArg::arg().get_long().unwrap_or_default());
let short_arg = format!("-{}", ProfileArg::arg().get_short().unwrap_or_default());

args.windows(2)
.find_map(|window| {
if window[0] == ProfileArg::arg().get_long().unwrap_or_default()
|| window[0]
== ProfileArg::arg()
.get_short()
.unwrap_or_default()
.to_string()
{
if window[0] == long_arg || window[0] == short_arg {
Some(window[1].clone())
} else {
None
Expand Down

0 comments on commit 32956cb

Please sign in to comment.