api: allow () type, but panic when used as CLI input
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
a7b9c8d89e
commit
5be4143d92
@ -312,6 +312,7 @@ macro_rules! unconstrained_api_type {
|
||||
|
||||
unconstrained_api_type! {Value} // basically our API's "any" type
|
||||
unconstrained_api_type! {String, &str}
|
||||
unconstrained_api_type! {()}
|
||||
unconstrained_api_type! {bool}
|
||||
unconstrained_api_type! {isize, usize, i64, u64, i32, u32, i16, u16, i8, u8, f64, f32}
|
||||
unconstrained_api_type! {Vec<String>}
|
||||
|
@ -341,6 +341,12 @@ macro_rules! derive_parse_cli_from_str {
|
||||
|
||||
derive_parse_cli_from_str! {isize, usize, i64, u64, i32, u32, i16, u16, i8, u8, f64, f32}
|
||||
|
||||
impl ParseCli for () {
|
||||
fn parse_cli(_name: &str, _value: Option<&str>) -> Result<Value, Error> {
|
||||
panic!("() type must not be used in command line interface!");
|
||||
}
|
||||
}
|
||||
|
||||
impl ParseCli for bool {
|
||||
fn parse_cli(name: &str, value: Option<&str>) -> Result<Value, Error> {
|
||||
// for booleans, using `--arg` without an option counts as `true`:
|
||||
|
Loading…
x
Reference in New Issue
Block a user