[librsvg/update-clap: 6/11] Parse the background-color option by hand




commit 27d5ed1fd2511c21205f0020311fb97ca5ce12c6
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Sep 20 11:14:30 2022 -0500

    Parse the background-color option by hand
    
    Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/748>

 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]