-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Chawye Hsu <su+git@chawyehsu.com>
- Loading branch information
Showing
4 changed files
with
47 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use clap::Parser; | ||
|
||
use crate::utils::detect_active_toolchain; | ||
|
||
/// Show the actual binary that will be run for a given command | ||
#[derive(Parser, Debug)] | ||
#[clap(arg_required_else_help = true)] | ||
pub struct Args { | ||
/// The command to inspect | ||
command: String, | ||
} | ||
|
||
pub async fn execute(args: Args) -> miette::Result<()> { | ||
let command_name = { | ||
let name = args.command.as_str(); | ||
|
||
#[cfg(target_os = "windows")] | ||
{ | ||
if !name.ends_with(".exe") { | ||
format!("{}.exe", name) | ||
} else { | ||
name.to_string() | ||
} | ||
} | ||
|
||
#[cfg(not(target_os = "windows"))] | ||
name.to_string() | ||
}; | ||
let mut active_toolchain = detect_active_toolchain(); | ||
|
||
active_toolchain.push("bin"); | ||
active_toolchain.push(command_name); | ||
|
||
if active_toolchain.exists() { | ||
println!("{}", active_toolchain.display()); | ||
} else { | ||
eprintln!("No command for '{}'", active_toolchain.display()); | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters