5ba885dbc4
Allow taking the `--input` argument to `imdl torrent create` as a positional argument, so the following now works: imdl torrent create foo Taking input by flag `--input` still works. type: changed fixes: - https://github.com/casey/intermodal/issues/375
18 lines
356 B
Rust
18 lines
356 B
Rust
use crate::common::*;
|
|
|
|
pub(crate) fn xor_args<T: Clone>(
|
|
a_name: &str,
|
|
a: &Option<T>,
|
|
b_name: &str,
|
|
b: &Option<T>,
|
|
) -> Result<T> {
|
|
let target = a.as_ref().xor(b.as_ref()).ok_or_else(|| {
|
|
Error::internal(format!(
|
|
"Expected exactly one of the arguments `{}` or `{}` to be set",
|
|
a_name, b_name
|
|
))
|
|
})?;
|
|
|
|
Ok(target.clone())
|
|
}
|