-
Hi. For example, my app supports custom list arg values that consist of an enum value and optional path string. #[arg(
id = "data",
help = "List of key-value export parameters formatted as `key=output`, where `output` is an output file path.\nSupports multiple occurences prefixed by --data or delimited by ','",
long,
short = 'd',
conflicts_with = "output",
value_parser = ExportOptionParser,
value_delimiter = ','
)]
pub data: Vec<(ExportData, Option<PathBuf>)>, So it can support lists like Though the shell may remove escapes, when explicit such as "a"
"b=\'a"
"test.txt\'" So my question is basically if there's a way to support either of:
For reference: quietvoid/dovi_tool#284 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
There can be a lot of caveats to escaping that I worry that fully supporting it would over-complicate clap's API, bloat the API, and negatively affect binary size and build times for little gain. I lean towards this being handled by callers in Some things to know
|
Beta Was this translation helpful? Give feedback.
-
Thanks, I guess it is possible only with a custom parser but I'd rather not have to handle it all myself. |
Beta Was this translation helpful? Give feedback.
There can be a lot of caveats to escaping that I worry that fully supporting it would over-complicate clap's API, bloat the API, and negatively affect binary size and build times for little gain. I lean towards this being handled by callers in
TypedValueParser
implementations (note that functions of the right signature implement that trait).Some things to know
Vec
which would make your field aVec<Vec<_>>
. It looks like that doesn't have special meaning in clap (some have requested it in the past) so you are likely fine with thatOsStr
, you'll need to work withOsStr::as_encoded_bytes
andOsStr::from_encoded_bytes_un…