[librsvg/update-clap: 2/11] WIP: Update clap to 3.2.22




commit 5c28d96881f0a4256d446e2a0207e36a2ee6c03b
Author: Federico Mena Quintero <federico gnome org>
Date:   Mon Sep 19 14:31:46 2022 -0500

    WIP: Update clap to 3.2.22
    
    - Bump version in Cargo.toml; use the "cargo" feature since the
      crate_version!() macro is now gated.
    
    - short("x") -> short('x')  - takes a char now
    
    - Add a Resolution newtype and a parser/validator.
    
    - Add a ZoomFactor newtype and a parser/validator.
    
    - arg_enum! -> #[derive(ValueEnum)]
    
    - value_t!() -> ArgMatches::get_one()
    
    - matches.is_present() -> matches.contains_id()
    
    This compiles, but the tests fail.
    
    Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/748>

 Cargo.lock              | 312 +++++++++++++++++++++++++++---------------------
 Cargo.toml              |   2 +-
 src/bin/rsvg-convert.rs | 241 +++++++++++++++++--------------------
 src/lib.rs              |   2 +-
 4 files changed, 289 insertions(+), 268 deletions(-)
---
diff --git a/Cargo.lock b/Cargo.lock
index e17c1ab76..c130f1334 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -8,44 +8,29 @@ version = "1.0.2"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
 
-[[package]]
-name = "adler32"
-version = "1.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234"
-
 [[package]]
 name = "aho-corasick"
-version = "0.7.18"
+version = "0.7.19"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
+checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e"
 dependencies = [
  "memchr",
 ]
 
 [[package]]
 name = "android_system_properties"
-version = "0.1.4"
+version = "0.1.5"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "d7ed72e1635e121ca3e79420540282af22da58be50de153d36f81ddc6b83aa9e"
+checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
 dependencies = [
  "libc",
 ]
 
-[[package]]
-name = "ansi_term"
-version = "0.12.1"
-source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
-dependencies = [
- "winapi",
-]
-
 [[package]]
 name = "anyhow"
-version = "1.0.62"
+version = "1.0.65"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "1485d4d2cc45e7b201ee3767015c96faa5904387c9d87c6efdd0fb511f12d305"
+checksum = "98161a4e3e2184da77bb14f02184cdd111e83bbbcc9979dfee3c44b9a85f5602"
 
 [[package]]
 name = "approx"
@@ -216,13 +201,48 @@ version = "2.34.0"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
 dependencies = [
- "ansi_term",
+ "bitflags",
+ "textwrap 0.11.0",
+ "unicode-width",
+]
+
+[[package]]
+name = "clap"
+version = "3.2.22"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "86447ad904c7fb335a790c9d7fe3d0d971dc523b8ccd1561a520de9a85302750"
+dependencies = [
  "atty",
  "bitflags",
+ "clap_derive",
+ "clap_lex",
+ "indexmap",
+ "once_cell",
  "strsim",
- "textwrap",
- "unicode-width",
- "vec_map",
+ "termcolor",
+ "textwrap 0.15.1",
+]
+
+[[package]]
+name = "clap_derive"
+version = "3.2.18"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65"
+dependencies = [
+ "heck",
+ "proc-macro-error",
+ "proc-macro2 1.0.43",
+ "quote 1.0.21",
+ "syn 1.0.100",
+]
+
+[[package]]
+name = "clap_lex"
+version = "0.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5"
+dependencies = [
+ "os_str_bytes",
 ]
 
 [[package]]
@@ -266,7 +286,7 @@ checksum = "b01d6de93b2b6c65e17c634a26653a29d107b3c98c607c765bf38d041531cd8f"
 dependencies = [
  "atty",
  "cast",
- "clap",
+ "clap 2.34.0",
  "criterion-plot",
  "csv",
  "itertools",
@@ -353,7 +373,7 @@ dependencies = [
  "proc-macro2 1.0.43",
  "quote 1.0.21",
  "smallvec",
- "syn 1.0.99",
+ "syn 1.0.100",
 ]
 
 [[package]]
@@ -363,7 +383,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index";
 checksum = "dfae75de57f2b2e85e8768c3ea840fd159c8f33e2b6522c7835b7abac81be16e"
 dependencies = [
  "quote 1.0.21",
- "syn 1.0.99",
+ "syn 1.0.100",
 ]
 
 [[package]]
@@ -397,15 +417,6 @@ dependencies = [
  "matches",
 ]
 
-[[package]]
-name = "deflate"
-version = "1.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "c86f7e25f518f4b81808a2cf1c50996a61f5c2eb394b2393bd87f2a4780a432f"
-dependencies = [
- "adler32",
-]
-
 [[package]]
 name = "derive_more"
 version = "0.99.17"
@@ -416,7 +427,7 @@ dependencies = [
  "proc-macro2 1.0.43",
  "quote 1.0.21",
  "rustc_version 0.4.0",
- "syn 1.0.99",
+ "syn 1.0.100",
 ]
 
 [[package]]
@@ -558,11 +569,10 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
 
 [[package]]
 name = "form_urlencoded"
-version = "1.0.1"
+version = "1.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191"
+checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8"
 dependencies = [
- "matches",
  "percent-encoding",
 ]
 
@@ -578,24 +588,24 @@ dependencies = [
 
 [[package]]
 name = "futures-channel"
-version = "0.3.23"
+version = "0.3.24"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "2bfc52cbddcfd745bf1740338492bb0bd83d76c67b445f91c5fb29fae29ecaa1"
+checksum = "30bdd20c28fadd505d0fd6712cdfcb0d4b5648baf45faef7f852afb2399bb050"
 dependencies = [
  "futures-core",
 ]
 
 [[package]]
 name = "futures-core"
-version = "0.3.23"
+version = "0.3.24"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "d2acedae88d38235936c3922476b10fced7b2b68136f5e3c03c2d5be348a1115"
+checksum = "4e5aa3de05362c3fb88de6531e6296e85cde7739cccad4b9dfeeb7f6ebce56bf"
 
 [[package]]
 name = "futures-executor"
-version = "0.3.23"
+version = "0.3.24"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "1d11aa21b5b587a64682c0094c2bdd4df0076c5324961a40cc3abd7f37930528"
+checksum = "9ff63c23854bee61b6e9cd331d523909f238fc7636290b96826e9cfa5faa00ab"
 dependencies = [
  "futures-core",
  "futures-task",
@@ -604,21 +614,21 @@ dependencies = [
 
 [[package]]
 name = "futures-io"
-version = "0.3.23"
+version = "0.3.24"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "93a66fc6d035a26a3ae255a6d2bca35eda63ae4c5512bef54449113f7a1228e5"
+checksum = "bbf4d2a7a308fd4578637c0b17c7e1c7ba127b8f6ba00b29f717e9655d85eb68"
 
 [[package]]
 name = "futures-task"
-version = "0.3.23"
+version = "0.3.24"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "842fc63b931f4056a24d59de13fb1272134ce261816e063e634ad0c15cdc5306"
+checksum = "a6508c467c73851293f390476d4491cf4d227dbabcd4170f3bb6044959b294f1"
 
 [[package]]
 name = "futures-util"
-version = "0.3.23"
+version = "0.3.24"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "f0828a5471e340229c11c77ca80017937ce3c58cb788a17e5f1c2d5c485a9577"
+checksum = "44fb6cb1be61cc1d2e43b262516aafcf63b241cffdb1d3fa115f91d9c7b09c90"
 dependencies = [
  "futures-core",
  "futures-task",
@@ -746,7 +756,7 @@ dependencies = [
  "proc-macro-error",
  "proc-macro2 1.0.43",
  "quote 1.0.21",
- "syn 1.0.99",
+ "syn 1.0.100",
 ]
 
 [[package]]
@@ -782,6 +792,12 @@ version = "1.8.2"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7"
 
+[[package]]
+name = "hashbrown"
+version = "0.12.3"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
+
 [[package]]
 name = "heck"
 version = "0.4.0"
@@ -799,28 +815,38 @@ dependencies = [
 
 [[package]]
 name = "iana-time-zone"
-version = "0.1.46"
+version = "0.1.48"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "ad2bfd338099682614d3ee3fe0cd72e0b6a41ca6a87f6a74a3bd593c91650501"
+checksum = "237a0714f28b1ee39ccec0770ccb544eb02c9ef2c82bb096230eefcffa6468b0"
 dependencies = [
  "android_system_properties",
  "core-foundation-sys",
  "js-sys",
+ "once_cell",
  "wasm-bindgen",
  "winapi",
 ]
 
 [[package]]
 name = "idna"
-version = "0.2.3"
+version = "0.3.0"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8"
+checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6"
 dependencies = [
- "matches",
  "unicode-bidi",
  "unicode-normalization",
 ]
 
+[[package]]
+name = "indexmap"
+version = "1.9.1"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e"
+dependencies = [
+ "autocfg",
+ "hashbrown",
+]
+
 [[package]]
 name = "instant"
 version = "0.1.12"
@@ -832,9 +858,9 @@ dependencies = [
 
 [[package]]
 name = "itertools"
-version = "0.10.3"
+version = "0.10.4"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3"
+checksum = "d8bf247779e67a9082a4790b45e71ac7cfd1321331a5c856a74a9faebdab78d0"
 dependencies = [
  "either",
 ]
@@ -853,9 +879,9 @@ checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754"
 
 [[package]]
 name = "js-sys"
-version = "0.3.59"
+version = "0.3.60"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "258451ab10b34f8af53416d1fdab72c22e805f0c92a1136d59470ec0b11138b2"
+checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47"
 dependencies = [
  "wasm-bindgen",
 ]
@@ -874,9 +900,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
 
 [[package]]
 name = "libc"
-version = "0.2.132"
+version = "0.2.133"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5"
+checksum = "c0f80d65747a3e43d1596c7c5492d95d5edddaabd45a7fcdb02b95f644164966"
 
 [[package]]
 name = "librsvg"
@@ -888,7 +914,7 @@ dependencies = [
  "cairo-rs",
  "cast",
  "chrono",
- "clap",
+ "clap 3.2.22",
  "criterion",
  "cssparser",
  "data-url",
@@ -950,9 +976,9 @@ dependencies = [
 
 [[package]]
 name = "lock_api"
-version = "0.4.7"
+version = "0.4.8"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53"
+checksum = "9f80bf5aacaf25cbfc8210d1cfb718f2bf3b11c4c54e5afe36c236853a8ec390"
 dependencies = [
  "autocfg",
  "scopeguard",
@@ -1052,9 +1078,9 @@ dependencies = [
 
 [[package]]
 name = "miniz_oxide"
-version = "0.5.3"
+version = "0.5.4"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "6f5c75688da582b8ffc1f1799e9db273f32133c49e048f614d22ec3256773ccc"
+checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34"
 dependencies = [
  "adler",
 ]
@@ -1083,7 +1109,7 @@ checksum = "01fcc0b8149b4632adc89ac3b7b31a12fb6099a0317a4eb2ebff574ef7de7218"
 dependencies = [
  "proc-macro2 1.0.43",
  "quote 1.0.21",
- "syn 1.0.99",
+ "syn 1.0.100",
 ]
 
 [[package]]
@@ -1184,9 +1210,9 @@ dependencies = [
 
 [[package]]
 name = "once_cell"
-version = "1.13.1"
+version = "1.14.0"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "074864da206b4973b84eb91683020dbefd6a8c3f0f38e054d93954e891935e4e"
+checksum = "2f7254b99e31cad77da24b08ebf628882739a608578bb1bcdfc1f9c21260d7c0"
 
 [[package]]
 name = "oorandom"
@@ -1194,6 +1220,12 @@ version = "11.1.3"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575"
 
+[[package]]
+name = "os_str_bytes"
+version = "6.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff"
+
 [[package]]
 name = "pango"
 version = "0.15.10"
@@ -1271,15 +1303,15 @@ dependencies = [
 
 [[package]]
 name = "paste"
-version = "1.0.8"
+version = "1.0.9"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "9423e2b32f7a043629287a536f21951e8c6a82482d0acb1eeebfc90bc2225b22"
+checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1"
 
 [[package]]
 name = "percent-encoding"
-version = "2.1.0"
+version = "2.2.0"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
+checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e"
 
 [[package]]
 name = "phf"
@@ -1333,7 +1365,7 @@ dependencies = [
  "proc-macro-hack",
  "proc-macro2 1.0.43",
  "quote 1.0.21",
- "syn 1.0.99",
+ "syn 1.0.100",
 ]
 
 [[package]]
@@ -1374,9 +1406,9 @@ checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae"
 
 [[package]]
 name = "plotters"
-version = "0.3.3"
+version = "0.3.4"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "716b4eeb6c4a1d3ecc956f75b43ec2e8e8ba80026413e70a3f41fd3313d3492b"
+checksum = "2538b639e642295546c50fcd545198c9d64ee2a38620a628724a3b266d5fbf97"
 dependencies = [
  "num-traits",
  "plotters-backend",
@@ -1402,13 +1434,13 @@ dependencies = [
 
 [[package]]
 name = "png"
-version = "0.17.5"
+version = "0.17.6"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "dc38c0ad57efb786dd57b9864e5b18bae478c00c824dc55a38bbc9da95dde3ba"
+checksum = "8f0e7f4c94ec26ff209cee506314212639d6c91b80afb82984819fafce9df01c"
 dependencies = [
  "bitflags",
  "crc32fast",
- "deflate",
+ "flate2",
  "miniz_oxide",
 ]
 
@@ -1480,7 +1512,7 @@ dependencies = [
  "proc-macro-error-attr",
  "proc-macro2 1.0.43",
  "quote 1.0.21",
- "syn 1.0.99",
+ "syn 1.0.100",
  "version_check",
 ]
 
@@ -1591,7 +1623,7 @@ checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
 dependencies = [
  "libc",
  "rand_chacha 0.3.1",
- "rand_core 0.6.3",
+ "rand_core 0.6.4",
 ]
 
 [[package]]
@@ -1611,7 +1643,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index";
 checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
 dependencies = [
  "ppv-lite86",
- "rand_core 0.6.3",
+ "rand_core 0.6.4",
 ]
 
 [[package]]
@@ -1625,9 +1657,9 @@ dependencies = [
 
 [[package]]
 name = "rand_core"
-version = "0.6.3"
+version = "0.6.4"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
+checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
 dependencies = [
  "getrandom 0.2.7",
 ]
@@ -1656,7 +1688,7 @@ version = "0.3.0"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f"
 dependencies = [
- "rand_core 0.6.3",
+ "rand_core 0.6.4",
 ]
 
 [[package]]
@@ -1738,9 +1770,9 @@ dependencies = [
 
 [[package]]
 name = "rgb"
-version = "0.8.33"
+version = "0.8.34"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "c3b221de559e4a29df3b957eec92bc0de6bc8eaf6ca9cfed43e5e1d67ff65a34"
+checksum = "3603b7d71ca82644f79b5a06d1220e9a58ede60bd32255f698cb1af8838b8db3"
 dependencies = [
  "bytemuck",
 ]
@@ -1760,7 +1792,7 @@ version = "0.4.0"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
 dependencies = [
- "semver 1.0.13",
+ "semver 1.0.14",
 ]
 
 [[package]]
@@ -1834,9 +1866,9 @@ dependencies = [
 
 [[package]]
 name = "semver"
-version = "1.0.13"
+version = "1.0.14"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "93f6841e709003d68bb2deee8c343572bf446003ec20a583e76f7b15cebf3711"
+checksum = "e25dfac463d778e353db5be2449d1cce89bd6fd23c9f1ea21310ce6e5a1b29c4"
 
 [[package]]
 name = "semver-parser"
@@ -1871,7 +1903,7 @@ checksum = "94ed3a816fb1d101812f83e789f888322c34e291f894f19590dc310963e87a00"
 dependencies = [
  "proc-macro2 1.0.43",
  "quote 1.0.21",
- "syn 1.0.99",
+ "syn 1.0.100",
 ]
 
 [[package]]
@@ -1983,7 +2015,7 @@ dependencies = [
  "quote 1.0.21",
  "serde",
  "serde_derive",
- "syn 1.0.99",
+ "syn 1.0.100",
 ]
 
 [[package]]
@@ -1999,7 +2031,7 @@ dependencies = [
  "serde_derive",
  "serde_json",
  "sha1",
- "syn 1.0.99",
+ "syn 1.0.100",
 ]
 
 [[package]]
@@ -2036,9 +2068,9 @@ dependencies = [
 
 [[package]]
 name = "strsim"
-version = "0.8.0"
+version = "0.10.0"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
+checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
 
 [[package]]
 name = "syn"
@@ -2053,9 +2085,9 @@ dependencies = [
 
 [[package]]
 name = "syn"
-version = "1.0.99"
+version = "1.0.100"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "58dbef6ec655055e20b86b15a8cc6d439cca19b667537ac6a1369572d151ab13"
+checksum = "52205623b1b0f064a4e71182c3b18ae902267282930c6d5462c91b859668426e"
 dependencies = [
  "proc-macro2 1.0.43",
  "quote 1.0.21",
@@ -2100,6 +2132,15 @@ dependencies = [
  "utf-8",
 ]
 
+[[package]]
+name = "termcolor"
+version = "1.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
+dependencies = [
+ "winapi-util",
+]
+
 [[package]]
 name = "termtree"
 version = "0.2.4"
@@ -2127,24 +2168,30 @@ dependencies = [
  "unicode-width",
 ]
 
+[[package]]
+name = "textwrap"
+version = "0.15.1"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "949517c0cf1bf4ee812e2e07e08ab448e3ae0d23472aee8a06c985f0c8815b16"
+
 [[package]]
 name = "thiserror"
-version = "1.0.32"
+version = "1.0.35"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "f5f6586b7f764adc0231f4c79be7b920e766bb2f3e51b3661cdb263828f19994"
+checksum = "c53f98874615aea268107765aa1ed8f6116782501d18e53d08b471733bea6c85"
 dependencies = [
  "thiserror-impl",
 ]
 
 [[package]]
 name = "thiserror-impl"
-version = "1.0.32"
+version = "1.0.35"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "12bafc5b54507e0149cdf1b145a5d80ab80a90bcd9275df43d4fff68460f6c21"
+checksum = "f8b463991b4eab2d801e724172285ec4195c650e8ec79b149e6c2a8e6dd3f783"
 dependencies = [
  "proc-macro2 1.0.43",
  "quote 1.0.21",
- "syn 1.0.99",
+ "syn 1.0.100",
 ]
 
 [[package]]
@@ -2193,7 +2240,7 @@ dependencies = [
  "proc-macro2 1.0.43",
  "quote 1.0.21",
  "standback",
- "syn 1.0.99",
+ "syn 1.0.100",
 ]
 
 [[package]]
@@ -2244,24 +2291,24 @@ checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992"
 
 [[package]]
 name = "unicode-ident"
-version = "1.0.3"
+version = "1.0.4"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf"
+checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd"
 
 [[package]]
 name = "unicode-normalization"
-version = "0.1.21"
+version = "0.1.22"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "854cbdc4f7bc6ae19c820d44abdc3277ac3e1b2b93db20a636825d9322fb60e6"
+checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921"
 dependencies = [
  "tinyvec",
 ]
 
 [[package]]
 name = "unicode-width"
-version = "0.1.9"
+version = "0.1.10"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
+checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
 
 [[package]]
 name = "unicode-xid"
@@ -2271,13 +2318,12 @@ checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
 
 [[package]]
 name = "url"
-version = "2.2.2"
+version = "2.3.1"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c"
+checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643"
 dependencies = [
  "form_urlencoded",
  "idna",
- "matches",
  "percent-encoding",
 ]
 
@@ -2287,12 +2333,6 @@ version = "0.7.6"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
 
-[[package]]
-name = "vec_map"
-version = "0.8.2"
-source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
-
 [[package]]
 name = "version-compare"
 version = "0.1.0"
@@ -2345,9 +2385,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
 
 [[package]]
 name = "wasm-bindgen"
-version = "0.2.82"
+version = "0.2.83"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "fc7652e3f6c4706c8d9cd54832c4a4ccb9b5336e2c3bd154d5cccfbf1c1f5f7d"
+checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268"
 dependencies = [
  "cfg-if",
  "wasm-bindgen-macro",
@@ -2355,24 +2395,24 @@ dependencies = [
 
 [[package]]
 name = "wasm-bindgen-backend"
-version = "0.2.82"
+version = "0.2.83"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "662cd44805586bd52971b9586b1df85cdbbd9112e4ef4d8f41559c334dc6ac3f"
+checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142"
 dependencies = [
  "bumpalo",
  "log",
  "once_cell",
  "proc-macro2 1.0.43",
  "quote 1.0.21",
- "syn 1.0.99",
+ "syn 1.0.100",
  "wasm-bindgen-shared",
 ]
 
 [[package]]
 name = "wasm-bindgen-macro"
-version = "0.2.82"
+version = "0.2.83"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "b260f13d3012071dfb1512849c033b1925038373aea48ced3012c09df952c602"
+checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810"
 dependencies = [
  "quote 1.0.21",
  "wasm-bindgen-macro-support",
@@ -2380,28 +2420,28 @@ dependencies = [
 
 [[package]]
 name = "wasm-bindgen-macro-support"
-version = "0.2.82"
+version = "0.2.83"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "5be8e654bdd9b79216c2929ab90721aa82faf65c48cdf08bdc4e7f51357b80da"
+checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c"
 dependencies = [
  "proc-macro2 1.0.43",
  "quote 1.0.21",
- "syn 1.0.99",
+ "syn 1.0.100",
  "wasm-bindgen-backend",
  "wasm-bindgen-shared",
 ]
 
 [[package]]
 name = "wasm-bindgen-shared"
-version = "0.2.82"
+version = "0.2.83"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "6598dd0bd3c7d51095ff6531a5b23e02acdc81804e30d8f07afb77b7215a140a"
+checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f"
 
 [[package]]
 name = "web-sys"
-version = "0.3.59"
+version = "0.3.60"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "ed055ab27f941423197eb86b2035720b1a3ce40504df082cac2ecc6ed73335a1"
+checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f"
 dependencies = [
  "js-sys",
  "wasm-bindgen",
diff --git a/Cargo.toml b/Cargo.toml
index 2b29accde..474aa8f47 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -51,7 +51,7 @@ byteorder = "1.4"
 cairo-rs = { version = "0.15", features=["v1_16", "png", "pdf", "ps", "svg"] }
 cast = "0.3.0"
 chrono = "0.4.0" # rsvg-convert
-clap = "2.34.0" # rsvg-convert
+clap = { version = "3.2.22", features = ["cargo", "derive"] } # rsvg-convert
 cssparser = "0.28.0"
 data-url = "0.1"
 encoding = "0.2.33"
diff --git a/src/bin/rsvg-convert.rs b/src/bin/rsvg-convert.rs
index b0a5f8da2..8f8efd6ed 100644
--- a/src/bin/rsvg-convert.rs
+++ b/src/bin/rsvg-convert.rs
@@ -1,4 +1,4 @@
-use clap::{arg_enum, crate_version, value_t};
+use clap::{ValueEnum, crate_version};
 
 use gio::prelude::*;
 use gio::{Cancellable, FileCreateFlags, InputStream, OutputStream};
@@ -20,7 +20,7 @@ use self::windows_imports::*;
 
 use librsvg::rsvg_convert_only::{
     AspectRatio, CssLength, Dpi, Horizontal, LegacySize, Length, Normalize, NormalizeParams, Parse,
-    PathOrUrl, Rect, ULength, Validate, Vertical, ViewBox,
+    PathOrUrl, Rect, Signed, ULength, Unsigned, Validate, Vertical, ViewBox,
 };
 use librsvg::{AcceptLanguage, CairoRenderer, Color, Language, LengthUnit, Loader, RenderingError};
 use std::ops::Deref;
@@ -468,20 +468,19 @@ impl std::fmt::Display for Output {
     }
 }
 
-arg_enum! {
-    // Keep this enum in sync with supported_formats in parse_args()
-    #[derive(Clone, Copy, Debug)]
-    enum Format {
-        Png,
-        Pdf,
-        Ps,
-        Eps,
-        Svg,
-    }
+// Keep this enum in sync with supported_formats in parse_args()
+#[derive(ValueEnum, Clone, Copy, Debug)]
+enum Format {
+    Png,
+    Pdf,
+    Ps,
+    Eps,
+    Svg,
 }
 
 struct Converter {
-    pub dpi: (f64, f64),
+    pub dpi_x: Resolution,
+    pub dpi_y: Resolution,
     pub zoom: Scale,
     pub width: Option<ULength<Horizontal>>,
     pub height: Option<ULength<Vertical>>,
@@ -555,7 +554,7 @@ impl Converter {
             }
 
             let renderer = CairoRenderer::new(&handle)
-                .with_dpi(self.dpi.0, self.dpi.1)
+                .with_dpi(self.dpi_x.0, self.dpi_y.0)
                 .with_language(&self.language)
                 .test_mode(self.testing);
 
@@ -563,7 +562,7 @@ impl Converter {
 
             let natural_size = Size::new(geometry.width, geometry.height);
 
-            let params = NormalizeParams::from_dpi(Dpi::new(self.dpi.0, self.dpi.1));
+            let params = NormalizeParams::from_dpi(Dpi::new(self.dpi_x.0, self.dpi_y.0));
 
             // Convert natural size and requested size to pixels or points, depending on the target format,
             let (natural_size, requested_width, requested_height, page_size) = match self.format {
@@ -779,74 +778,76 @@ fn parse_args() -> Result<Converter, Error> {
         "Svg",
     ];
 
-    let app = clap::App::new("rsvg-convert")
+    let app = clap::Command::new("rsvg-convert")
         .version(concat!("version ", crate_version!()))
         .about("Convert SVG files to other image formats")
-        .help_short("?")
-        .version_short("v")
+        .help_short('?')
+        .version_short('v')
         .arg(
             clap::Arg::with_name("res_x")
-                .short("d")
+                .short('d')
                 .long("dpi-x")
                 .takes_value(true)
                 .value_name("number")
                 .default_value("96")
-                .validator(is_valid_resolution)
+                .value_parser(parse_resolution)
                 .help("Pixels per inch"),
         )
         .arg(
             clap::Arg::with_name("res_y")
-                .short("p")
+                .short('p')
                 .long("dpi-y")
                 .takes_value(true)
                 .value_name("number")
                 .default_value("96")
-                .validator(is_valid_resolution)
+                .value_parser(parse_resolution)
                 .help("Pixels per inch"),
         )
         .arg(
             clap::Arg::with_name("zoom_x")
-                .short("x")
+                .short('x')
                 .long("x-zoom")
                 .takes_value(true)
                 .value_name("number")
                 .conflicts_with("zoom")
-                .validator(is_valid_zoom_factor)
+                .value_parser(parse_zoom_factor)
                 .help("Horizontal zoom factor"),
         )
         .arg(
             clap::Arg::with_name("zoom_y")
-                .short("y")
+                .short('y')
                 .long("y-zoom")
                 .takes_value(true)
                 .value_name("number")
                 .conflicts_with("zoom")
-                .validator(is_valid_zoom_factor)
+                .value_parser(parse_zoom_factor)
                 .help("Vertical zoom factor"),
         )
         .arg(
             clap::Arg::with_name("zoom")
-                .short("z")
+                .short('z')
                 .long("zoom")
                 .takes_value(true)
                 .value_name("number")
-                .validator(is_valid_zoom_factor)
+                .value_parser(parse_zoom_factor)
                 .help("Zoom factor"),
         )
         .arg(
             clap::Arg::with_name("size_x")
-                .short("w")
+                .short('w')
                 .long("width")
                 .takes_value(true)
                 .value_name("length")
+                .value_parser(parse_length::<Horizontal, Unsigned>)
                 .help("Width [defaults to the width of the SVG]"),
         )
         .arg(
             clap::Arg::with_name("size_y")
-                .short("h")
+                .short('h')
                 .long("height")
                 .takes_value(true)
                 .value_name("length")
+                .value_parser(parse_length::<Vertical, Unsigned>)
                 .help("Height [defaults to the height of the SVG]"),
         )
         .arg(
@@ -854,6 +855,7 @@ fn parse_args() -> Result<Converter, Error> {
                 .long("top")
                 .takes_value(true)
                 .value_name("length")
+                .value_parser(parse_length::<Vertical, Signed>)
                 .help("Distance between top edge of page and the image [defaults to 0]"),
         )
         .arg(
@@ -861,6 +863,7 @@ fn parse_args() -> Result<Converter, Error> {
                 .long("left")
                 .takes_value(true)
                 .value_name("length")
+                .value_parser(parse_length::<Horizontal, Signed>)
                 .help("Distance between left edge of page and the image [defaults to 0]"),
         )
         .arg(
@@ -868,6 +871,7 @@ fn parse_args() -> Result<Converter, Error> {
                 .long("page-width")
                 .takes_value(true)
                 .value_name("length")
+                .value_parser(parse_length::<Horizontal, Unsigned>)
                 .help("Width of output media [defaults to the width of the SVG]"),
         )
         .arg(
@@ -875,11 +879,12 @@ fn parse_args() -> Result<Converter, Error> {
                 .long("page-height")
                 .takes_value(true)
                 .value_name("length")
+                .value_parser(parse_length::<Vertical, Unsigned>)
                 .help("Height of output media [defaults to the height of the SVG]"),
         )
         .arg(
             clap::Arg::with_name("format")
-                .short("f")
+                .short('f')
                 .long("format")
                 .takes_value(true)
                 .possible_values(supported_formats.as_slice())
@@ -889,14 +894,14 @@ fn parse_args() -> Result<Converter, Error> {
         )
         .arg(
             clap::Arg::with_name("output")
-                .short("o")
+                .short('o')
                 .long("output")
                 .empty_values(false)
                 .help("Output filename [defaults to stdout]"),
         )
         .arg(
             clap::Arg::with_name("export_id")
-                .short("i")
+                .short('i')
                 .long("export-id")
                 .empty_values(false)
                 .value_name("object id")
@@ -904,7 +909,7 @@ fn parse_args() -> Result<Converter, Error> {
         )
         .arg(
             clap::Arg::with_name("accept-language")
-                .short("l")
+                .short('l')
                 .long("accept-language")
                 .empty_values(false)
                 .value_name("languages")
@@ -912,21 +917,23 @@ fn parse_args() -> Result<Converter, Error> {
         )
         .arg(
             clap::Arg::with_name("keep_aspect")
-                .short("a")
+                .short('a')
                 .long("keep-aspect-ratio")
+                .default_value("false")
                 .help("Preserve the aspect ratio"),
         )
         .arg(
             clap::Arg::with_name("background")
-                .short("b")
+                .short('b')
                 .long("background-color")
                 .takes_value(true)
                 .value_name("color")
+                .value_parser(parse_background_color)
                 .help("Set the background color using a CSS color spec"),
         )
         .arg(
             clap::Arg::with_name("stylesheet")
-                .short("s")
+                .short('s')
                 .long("stylesheet")
                 .empty_values(false)
                 .value_name("filename.css")
@@ -934,7 +941,7 @@ fn parse_args() -> Result<Converter, Error> {
         )
         .arg(
             clap::Arg::with_name("unlimited")
-                .short("u")
+                .short('u')
                 .long("unlimited")
                 .help("Allow huge SVG files"),
         )
@@ -962,64 +969,44 @@ fn parse_args() -> Result<Converter, Error> {
 
     let matches = app.get_matches();
 
-    let format = value_t!(matches, "format", Format)?;
+    let format: Format = *matches.get_one("format").expect("already provided default_value");
 
     let keep_image_data = match format {
-        Format::Ps | Format::Eps | Format::Pdf => !matches.is_present("no_keep_image_data"),
-        _ => matches.is_present("keep_image_data"),
+        Format::Ps | Format::Eps | Format::Pdf => !matches.contains_id("no_keep_image_data"),
+        _ => matches.contains_id("keep_image_data"),
     };
 
-    let language = value_t!(matches, "accept-language", String)
-        .or_none()
-        .and_then(|lang_str| match lang_str {
-            None => Ok(Language::FromEnvironment),
-            Some(s) => AcceptLanguage::parse(&s)
-                .map(Language::AcceptLanguage)
-                .map_err(|e| {
-                    let desc = format!("{}", e);
-                    clap::Error::with_description(&desc, clap::ErrorKind::InvalidValue)
-                }),
-        });
+    let language = match matches.get_one::<String>("accept-language") {
+        None => Language::FromEnvironment,
+        Some(s) => AcceptLanguage::parse(&s)
+            .map(Language::AcceptLanguage)
+            .map_err(|e| {
+                let desc = format!("{}", e);
+                clap::Error::with_description(desc, clap::ErrorKind::InvalidValue)
+            })?,
+    };
 
-    let background_color = value_t!(matches, "background", String).and_then(parse_color_string);
+    let background_color: Option<Color> = matches.get_one("background").copied();
 
     // 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
     // the toplevel, and don't expect users to lookup things in externs.
-    let lookup_id = |id: String| {
+    let lookup_id = |id: &String| {
         if id.starts_with('#') {
-            id
+            id.clone()
         } else {
             format!("#{}", id)
         }
     };
 
-    let width = value_t!(matches, "size_x", String)
-        .or_none()?
-        .map(parse_length)
-        .transpose()?;
-    let height = value_t!(matches, "size_y", String)
-        .or_none()?
-        .map(parse_length)
-        .transpose()?;
-
-    let left = value_t!(matches, "left", String)
-        .or_none()?
-        .map(parse_length)
-        .transpose()?;
-    let top = value_t!(matches, "top", String)
-        .or_none()?
-        .map(parse_length)
-        .transpose()?;
-
-    let page_width = value_t!(matches, "page_width", String)
-        .or_none()?
-        .map(parse_length)
-        .transpose()?;
-    let page_height = value_t!(matches, "page_height", String)
-        .or_none()?
-        .map(parse_length)
-        .transpose()?;
+    let width: Option<ULength<Horizontal>> = matches.get_one("size_x").copied();
+    let height: Option<ULength<Vertical>> = matches.get_one("size_y").copied();
+
+    let left: Option<Length<Horizontal>> = matches.get_one("left").copied();
+    let top: Option<Length<Vertical>> = matches.get_one("top").copied();
+
+    let page_width: Option<ULength<Horizontal>> = matches.get_one("page_width").copied();
+    let page_height: Option<ULength<Vertical>> = matches.get_one("page_height").copied();
 
     let page_size = match (page_width, page_height) {
         (None, None) => None,
@@ -1031,9 +1018,12 @@ fn parse_args() -> Result<Converter, Error> {
         (Some(w), Some(h)) => Some((w, h)),
     };
 
-    let zoom = value_t!(matches, "zoom", f64).or_none()?;
-    let zoom_x = value_t!(matches, "zoom_x", f64).or_none()?;
-    let zoom_y = value_t!(matches, "zoom_y", f64).or_none()?;
+    let dpi_x = *matches.get_one::<Resolution>("res_x").expect("already provided default_value");
+    let dpi_y = *matches.get_one::<Resolution>("res_y").expect("already provided default_value");
+
+    let zoom: Option<ZoomFactor> = matches.get_one("zoom").copied();
+    let zoom_x: Option<ZoomFactor> = matches.get_one("zoom_x").copied();
+    let zoom_y: Option<ZoomFactor> = matches.get_one("zoom_y").copied();
 
     let input = match matches.values_of_os("FILE") {
         Some(values) => values
@@ -1050,14 +1040,16 @@ fn parse_args() -> Result<Converter, Error> {
         ));
     }
 
+    let keep_aspect_ratio = *matches.get_one("keep_aspect").expect("already provided default_value");
+
+    let export_id: Option<String> = matches.get_one::<String>("export_id").map(lookup_id);
+
     Ok(Converter {
-        dpi: (
-            value_t!(matches, "res_x", f64)?,
-            value_t!(matches, "res_y", f64)?,
-        ),
+        dpi_x,
+        dpi_y,
         zoom: Scale {
-            x: zoom.or(zoom_x).unwrap_or(1.0),
-            y: zoom.or(zoom_y).unwrap_or(1.0),
+            x: zoom.or(zoom_x).map(|factor| factor.0).unwrap_or(1.0),
+            y: zoom.or(zoom_y).map(|factor| factor.0).unwrap_or(1.0),
         },
         width,
         height,
@@ -1065,15 +1057,13 @@ fn parse_args() -> Result<Converter, Error> {
         top,
         page_size,
         format,
-        export_id: value_t!(matches, "export_id", String)
-            .or_none()?
-            .map(lookup_id),
-        keep_aspect_ratio: matches.is_present("keep_aspect"),
-        background_color: background_color.or_none()?,
+        export_id,
+        keep_aspect_ratio,
+        background_color,
         stylesheet: matches.value_of_os("stylesheet").map(PathBuf::from),
-        unlimited: matches.is_present("unlimited"),
+        unlimited: matches.contains_id("unlimited"),
         keep_image_data,
-        language: language?,
+        language,
         input,
         output: matches
             .value_of_os("output")
@@ -1084,17 +1074,23 @@ fn parse_args() -> Result<Converter, Error> {
     })
 }
 
-fn is_valid_resolution(v: String) -> Result<(), String> {
+#[derive(Copy, Clone)]
+struct Resolution(f64);
+
+fn parse_resolution(v: &str) -> Result<Resolution, String> {
     match v.parse::<f64>() {
-        Ok(res) if res > 0.0 => Ok(()),
+        Ok(res) if res > 0.0 => Ok(Resolution(res)),
         Ok(_) => Err(String::from("Invalid resolution")),
         Err(e) => Err(format!("{}", e)),
     }
 }
 
-fn is_valid_zoom_factor(v: String) -> Result<(), String> {
+#[derive(Copy, Clone)]
+struct ZoomFactor(f64);
+
+fn parse_zoom_factor(v: &str) -> Result<ZoomFactor, String> {
     match v.parse::<f64>() {
-        Ok(res) if res > 0.0 => Ok(()),
+        Ok(res) if res > 0.0 => Ok(ZoomFactor(res)),
         Ok(_) => Err(String::from("Invalid zoom factor")),
         Err(e) => Err(format!("{}", e)),
     }
@@ -1127,18 +1123,14 @@ impl<T> NotFound for Result<T, clap::Error> {
     }
 }
 
-fn parse_color_string<T: AsRef<str> + std::fmt::Display>(s: T) -> Result<Color, clap::Error> {
-    match s.as_ref() {
-        "none" | "None" => Err(clap::Error::with_description(
-            s.as_ref(),
-            clap::ErrorKind::ArgumentNotFound,
-        )),
-        _ => <Color as Parse>::parse_str(s.as_ref()).map_err(|_| {
-            let desc = format!(
+fn parse_background_color(s: &str) -> Result<Color, String> {
+    match s {
+        "none" | "None" => Err(format!("argument not found: {}", s)),
+        _ => <Color as Parse>::parse_str(s).map_err(|_| {
+            format!(
                 "Invalid value: The argument '{}' can not be parsed as a CSS color value",
                 s
-            );
-            clap::Error::with_description(&desc, clap::ErrorKind::InvalidValue)
+            )
         }),
     }
 }
@@ -1152,26 +1144,21 @@ fn is_absolute_unit(u: LengthUnit) -> bool {
     }
 }
 
-fn parse_length<N: Normalize, V: Validate>(s: String) -> Result<CssLength<N, V>, clap::Error> {
-    <CssLength<N, V> as Parse>::parse_str(&s)
+fn parse_length<N: Normalize, V: Validate>(s: &str) -> Result<CssLength<N, V>, String> {
+    <CssLength<N, V> as Parse>::parse_str(s)
         .map_err(|_| {
-            let desc = format!(
+            format!(
                 "Invalid value: The argument '{}' can not be parsed as a length",
                 s
-            );
-            clap::Error::with_description(&desc, clap::ErrorKind::InvalidValue)
+            )
         })
         .and_then(|l| {
             if is_absolute_unit(l.unit) {
                 Ok(l)
             } else {
-                let desc = format!(
+                Err(format!(
                     "Invalid value '{}': supported units are px, in, cm, mm, pt, pc",
                     s
-                );
-                Err(clap::Error::with_description(
-                    &desc,
-                    clap::ErrorKind::InvalidValue,
                 ))
             }
         })
@@ -1190,23 +1177,17 @@ mod color_tests {
 
     #[test]
     fn valid_color_is_ok() {
-        assert!(parse_color_string("Red").is_ok());
+        assert!(parse_background_color("Red").is_ok());
     }
 
     #[test]
     fn none_is_handled_as_not_found() {
-        assert_eq!(
-            parse_color_string("None").map_err(|e| e.kind),
-            Err(clap::ErrorKind::ArgumentNotFound)
-        );
+        assert!(parse_background_color("None").is_err());
     }
 
     #[test]
     fn invalid_is_handled_as_invalid_value() {
-        assert_eq!(
-            parse_color_string("foo").map_err(|e| e.kind),
-            Err(clap::ErrorKind::InvalidValue)
-        );
+        assert!(parse_background_color("foo").is_err());
     }
 }
 
diff --git a/src/lib.rs b/src/lib.rs
index 69be845ab..00f2bba5c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -249,7 +249,7 @@ pub mod rsvg_convert_only {
     pub use crate::dpi::Dpi;
     pub use crate::error::ParseError;
     pub use crate::length::{
-        CssLength, Horizontal, Length, Normalize, NormalizeParams, ULength, Validate, Vertical,
+        CssLength, Horizontal, Length, Normalize, NormalizeParams, Signed, ULength, Unsigned, Validate, 
Vertical,
     };
     pub use crate::parsers::{Parse, ParseValue};
     pub use crate::rect::Rect;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]