From bfe93f8d90390745d31278bddb72274779d4fb33 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Wed, 2 Mar 2022 10:19:53 +0100 Subject: [PATCH] Allow invoking the xtask library with custom args Useful when providing a cargo sub command. --- nih_plug_xtask/src/lib.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/nih_plug_xtask/src/lib.rs b/nih_plug_xtask/src/lib.rs index df014d03..87f9ff49 100644 --- a/nih_plug_xtask/src/lib.rs +++ b/nih_plug_xtask/src/lib.rs @@ -43,9 +43,16 @@ pub enum CompilationTarget { /// The main xtask entry point function. See the readme for instructions on how to use this. pub fn main() -> Result<()> { + let args = std::env::args().skip(1); + main_with_args(args) +} + +/// The main xtask entry point function, but with custom command line arguments. `args` should not +/// contain the command name, so you should always skip at least one argument from +/// `std::env::args()` before passing it to this function. +pub fn main_with_args(mut args: impl Iterator) -> Result<()> { chdir_workspace_root()?; - let mut args = std::env::args().skip(1); let command = args .next() .context(format!("Missing command name\n\n{USAGE_STRING}"))?;