[librsvg/update-clap] Parse the background-color option by hand
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/update-clap] Parse the background-color option by hand
- Date: Tue, 20 Sep 2022 16:53:10 +0000 (UTC)
commit 8eced7c4d12c138d8cd0a820cfdfd0e4bc8b55ba
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Sep 20 11:14:30 2022 -0500
Parse the background-color option by hand
src/bin/rsvg-convert.rs | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/src/bin/rsvg-convert.rs b/src/bin/rsvg-convert.rs
index 81139e8b7..b40439364 100644
--- a/src/bin/rsvg-convert.rs
+++ b/src/bin/rsvg-convert.rs
@@ -930,7 +930,7 @@ fn parse_args() -> Result<Converter, Error> {
.long("background-color")
.takes_value(true)
.value_name("color")
- .value_parser(parse_background_color)
+ .value_parser(clap::builder::NonEmptyStringValueParser::new())
.default_value("none")
.help("Set the background color using a CSS color spec"),
)
@@ -1001,7 +1001,11 @@ fn parse_args() -> Result<Converter, Error> {
})?,
};
- let background_color: Option<Color> = matches.get_one("background").copied();
+ let background_str: &String = matches
+ .get_one("background")
+ .expect("already provided default_value");
+ let background_color: Option<Color> = parse_background_color(&**background_str)
+ .map_err(|e| clap::Error::with_description(e, clap::ErrorKind::InvalidValue))?;
// librsvg expects ids starting with '#', so it can lookup ids in externs like "subfile.svg#subid".
// For the user's convenience, we prepend '#' automatically; we only support specifying ids from
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]