If an id is not found, it is more likely to be a typo than a value
which is serialized to `id_xxxx`. If the later case really happens,
the value can still be represented by the id_ syntax.
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
`help_text` generates the help message at runtime. It cannot be done
at compile time because proc macro cannot access the information of
sub-field types.
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
Trait `Help` returns a description of a type. It is used to generate
the help message for the command line interface.
The derive macro implements `Help` for enums and structs and
includes inline documentation in the description.
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
For a struct like
struct Foo {
path: PathBuf,
param: Option<String>,
}
to set `param` to `None`, it is more intuitive to write `path=foo`
than `path=foo,param=`. The latter looks more like setting `param` to
`Some("")`.
On the other hand, if the value is an id and the id points to an empty
string, it is interpreted as `None`.
Fixes: 8f3ba3445a ("fix(aco): differentiate `Some("")` from `None`")
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
This allows a value of a complex type to be serialized inline, given
its string representation contains neither a comma nor an equal sign.
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
The array `variants` passed from serde does not contain enum variant
aliases. Thus for an unit_variant that has an alias, the alias name
was interpreted as an object id and the deserialization failed.
On the other hand, for a non-in-value enum value, the full string was
passed to `Enum::new` and somehow serde can determine the variant
from `variant_seed`, even if the string is a variant alias.
Therefore, to make the in-value case work, the value string is always
interpreted as an object id first. If an object string cannot be
found, the object id is interpreted as the object string. In both two
cases, the object string is passed to `Enum::new` to let serde find
out which variant it is.
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
`serde-aco` is for parsing complex data structures from command line.
Nested structures can be expressed by multiple key-value pair
strings.
This crate is inspired by QEMU's `-object` flag.
Signed-off-by: Changyuan Lyu <changyuanl@google.com>