pub trait CommandExt {
// Required method
fn option(&mut self, name: &str, value: Option<impl Display>) -> &mut Self;
}std only.Expand description
Additional argument-building methods for Tokio Command.
Import this trait to chain optional named arguments with the command’s
existing arg, args, and standard-stream configuration methods.
use asimov_runner::{Command, CommandExt};
let mut command = Command::new("asimov-example-lister");
let before = Some(String::from("urn:example:entry:123"));
command
.option("sort", Some("name"))
.option("offset", None::<usize>)
.option("before", before.as_ref())
.option("limit", Some(25))
.arg("https://example.com/collection");
let args: Vec<_> = command.as_std().get_args().collect();
assert_eq!(args, [
"--sort=name",
"--before=urn:example:entry:123",
"--limit=25",
"https://example.com/collection",
]);Required Methods§
Sourcefn option(&mut self, name: &str, value: Option<impl Display>) -> &mut Self
fn option(&mut self, name: &str, value: Option<impl Display>) -> &mut Self
Appends --name=value for Some(value) and nothing for None.
name is the long option name without leading dashes. Values use
Display, accepting numbers, strings, and domain types such as sort
keys. Use as_ref() to borrow a non-Copy optional value. Some(0),
Some(false), and Some("") are explicit values and are not omitted.
Each present option is one literal argument, preserving invocation order,
spaces, and punctuation without shell escaping or expansion. Names and
values are not validated. Capability decisions remain with the caller:
use Option::filter to conditionally omit an otherwise present option.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".