mirror of
https://github.com/tareqimbasher/cargo-seek.git
synced 2026-01-09 07:52:41 +08:00
filter out subcommand from args
This commit is contained in:
parent
64fe276d0b
commit
41c6f66310
@ -8,7 +8,7 @@ fn get_current_dir() -> Option<PathBuf> {
|
||||
}
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(author, version = version(), about)]
|
||||
#[command(bin_name = "crate-seek", author, version = version(), about)]
|
||||
pub struct Cli {
|
||||
/// Specifies the root or subdirectory of a Cargo project
|
||||
#[arg(default_value=get_current_dir().unwrap_or_default().into_os_string())]
|
||||
|
||||
15
src/main.rs
15
src/main.rs
@ -20,7 +20,8 @@ async fn main() -> color_eyre::Result<()> {
|
||||
errors::init()?;
|
||||
logging::init()?;
|
||||
|
||||
let args = Cli::parse();
|
||||
let args = filter_subcommand(std::env::args().collect());
|
||||
let args = Cli::parse_from(args);
|
||||
let mut app = App::new(
|
||||
args.tick_rate,
|
||||
args.frame_rate,
|
||||
@ -31,3 +32,15 @@ async fn main() -> color_eyre::Result<()> {
|
||||
app.run().await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn filter_subcommand(args: Vec<String>) -> Vec<String> {
|
||||
// Check if the binary was invoked as a Cargo subcommand
|
||||
if args.get(1).map(String::as_str) == Some("seek") {
|
||||
// Skip the seek subcommand
|
||||
std::iter::once(args[0].clone())
|
||||
.chain(args.into_iter().skip(2))
|
||||
.collect()
|
||||
} else {
|
||||
args
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user