diff options
author | Marge Bot <marge-bot@gnome.org> | 2022-11-04 21:14:00 +0000 |
---|---|---|
committer | Marge Bot <marge-bot@gnome.org> | 2022-11-04 21:14:00 +0000 |
commit | 05542bbb120bc96bc76a868e2efc8d5eaf21c184 (patch) | |
tree | 0b47e3f8a0bbdab567a5a42adaa975feec2cedb6 | |
parent | e276654de2468f830853d462d5a17fe6dfe75cdc (diff) | |
parent | 7d6a9612fadd19ad21e6f3ecdb60d1e90a38c028 (diff) | |
download | librsvg-05542bbb120bc96bc76a868e2efc8d5eaf21c184.tar.gz |
Merge branch 'librsvg-fix_908' into 'main'
Update to clap 4
Closes #908
See merge request GNOME/librsvg!765
-rw-r--r-- | Cargo.lock | 145 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/bin/rsvg-convert.rs | 191 |
3 files changed, 187 insertions, 151 deletions
@@ -43,11 +43,11 @@ dependencies = [ [[package]] name = "assert_cmd" -version = "2.0.5" +version = "2.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5c2ca00549910ec251e3bd15f87aeeb206c9456b9a77b43ff6c97c54042a472" +checksum = "ba45b8163c49ab5f972e59a8a5a03b6d2972619d486e19ec9fe744f7c2753d3c" dependencies = [ - "bstr", + "bstr 1.0.1", "doc-comment", "predicates", "predicates-core", @@ -118,6 +118,18 @@ dependencies = [ ] [[package]] +name = "bstr" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fca0852af221f458706eb0725c03e4ed6c46af9ac98e6a689d5e634215d594dd" +dependencies = [ + "memchr", + "once_cell", + "regex-automata", + "serde", +] + +[[package]] name = "bumpalo" version = "3.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -125,9 +137,9 @@ checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" [[package]] name = "bytemuck" -version = "1.12.1" +version = "1.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f5715e491b5a1598fc2bef5a606847b5dc1d48ea625bd3c02c00de8285591da" +checksum = "5aec14f5d4e6e3f927cd0c81f72e5710d95ee9019fbeb4b3021193867491bfd8" [[package]] name = "byteorder" @@ -168,9 +180,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.73" +version = "1.0.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +checksum = "581f5dba903aac52ea3feb5ec4810848460ee833876f1f9b0fdeab1f19091574" [[package]] name = "cfg-expr" @@ -209,32 +221,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ "bitflags", - "textwrap 0.11.0", + "textwrap", "unicode-width", ] [[package]] name = "clap" -version = "3.2.22" +version = "4.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86447ad904c7fb335a790c9d7fe3d0d971dc523b8ccd1561a520de9a85302750" +checksum = "8e67816e006b17427c9b4386915109b494fec2d929c63e3bd3561234cbf1bf1e" dependencies = [ "atty", "bitflags", "clap_derive", "clap_lex", - "indexmap", "once_cell", "strsim", "termcolor", - "textwrap 0.15.1", ] [[package]] name = "clap_derive" -version = "3.2.18" +version = "4.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65" +checksum = "16a1b0f6422af32d5da0c58e2703320f379216ee70198241c84173a8c5ac28f3" dependencies = [ "heck", "proc-macro-error", @@ -245,9 +255,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.2.4" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" +checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8" dependencies = [ "os_str_bytes", ] @@ -407,7 +417,7 @@ version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" dependencies = [ - "bstr", + "bstr 0.2.17", "csv-core", "itoa 0.4.8", "ryu", @@ -425,9 +435,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.79" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f83d0ebf42c6eafb8d7c52f7e5f2d3003b89c7aa4fd2b79229209459a849af8" +checksum = "6b7d4e43b25d3c994662706a1d4fcfc32aaa6afd287502c111b237093bb23f3a" dependencies = [ "cc", "cxxbridge-flags", @@ -437,9 +447,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.79" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07d050484b55975889284352b0ffc2ecbda25c0c55978017c132b29ba0818a86" +checksum = "84f8829ddc213e2c1368e51a2564c552b65a8cb6a28f31e576270ac81d5e5827" dependencies = [ "cc", "codespan-reporting", @@ -452,15 +462,15 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.79" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99d2199b00553eda8012dfec8d3b1c75fce747cf27c169a270b3b99e3448ab78" +checksum = "e72537424b474af1460806647c41d4b6d35d09ef7fe031c5c2fa5766047cc56a" [[package]] name = "cxxbridge-macro" -version = "1.0.79" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcb67a6de1f602736dd7eaead0080cf3435df806c61b24b13328db128c58868f" +checksum = "309e4fb93eed90e1e14bea0da16b209f81813ba9fc7830c20ed151dd7bc0a4d7" dependencies = [ "proc-macro2 1.0.47", "quote 1.0.21", @@ -608,7 +618,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6" dependencies = [ "crc32fast", - "miniz_oxide", + "miniz_oxide 0.5.4", ] [[package]] @@ -767,9 +777,9 @@ dependencies = [ [[package]] name = "gio" -version = "0.16.0" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3025f17aab38ebbb40d785806cf36c292c4dd6755b05584fc52d34fb87533263" +checksum = "33c1debf8d0315d69be0153aa76249db3c858ef69b7778ad3cc669e6d370c485" dependencies = [ "bitflags", "futures-channel", @@ -800,9 +810,9 @@ dependencies = [ [[package]] name = "glib" -version = "0.16.1" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "079d580b26ee5eb504942bd4340a1218323a4cf19a31d776d62cd3a2a8416622" +checksum = "d5abffa711471e015eb93d65d6ea20e7e9f6f7951fc0a1042280439319b2de06" dependencies = [ "bitflags", "futures-channel", @@ -869,12 +879,6 @@ 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" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -891,9 +895,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.51" +version = "0.1.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5a6ef98976b22b3b7f2f3a806f858cb862044cfa66805aa3ad84cb3d3b785ed" +checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -924,16 +928,6 @@ dependencies = [ ] [[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" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -986,9 +980,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.135" +version = "0.2.137" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68783febc7782c6c5cb401fbda4de5a9898be1762314da0bb2c10ced61f18b0c" +checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" [[package]] name = "librsvg" @@ -1000,7 +994,7 @@ dependencies = [ "cairo-rs", "cast", "chrono", - "clap 3.2.22", + "clap 4.0.19", "criterion", "cssparser", "data-url", @@ -1181,6 +1175,15 @@ dependencies = [ ] [[package]] +name = "miniz_oxide" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" +dependencies = [ + "adler", +] + +[[package]] name = "nalgebra" version = "0.30.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1266,9 +1269,9 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.13.1" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" +checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5" dependencies = [ "hermit-abi", "libc", @@ -1305,9 +1308,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" +checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" [[package]] name = "oorandom" @@ -1317,9 +1320,9 @@ checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" [[package]] name = "os_str_bytes" -version = "6.3.0" +version = "6.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff" +checksum = "3baf96e39c5359d2eb0dd6ccb42c62b91d9678aa68160d261b9e0ccbf9e9dea9" [[package]] name = "pango" @@ -1496,9 +1499,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" +checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" [[package]] name = "plotters" @@ -1530,14 +1533,14 @@ dependencies = [ [[package]] name = "png" -version = "0.17.6" +version = "0.17.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f0e7f4c94ec26ff209cee506314212639d6c91b80afb82984819fafce9df01c" +checksum = "5d708eaf860a19b19ce538740d2b4bdeeb8337fa53f7738455e706623ad5c638" dependencies = [ "bitflags", "crc32fast", "flate2", - "miniz_oxide", + "miniz_oxide 0.6.2", ] [[package]] @@ -1980,9 +1983,9 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.145" +version = "1.0.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b" +checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" dependencies = [ "serde_derive", ] @@ -1999,9 +2002,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.145" +version = "1.0.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fa1584d3d1bcacd84c277a0dfe21f5b0f6accf4a23d04d4c6d61f1af522b4c" +checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852" dependencies = [ "proc-macro2 1.0.47", "quote 1.0.21", @@ -2046,9 +2049,9 @@ checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012" [[package]] name = "simba" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c48e45e5961033db030b56ad67aef22e9c908c493a6e8348c0a0f6b93433cd77" +checksum = "2f3fd720c48c53cace224ae62bef1bbff363a70c68c4802a78b5cc6159618176" dependencies = [ "approx", "num-complex", @@ -2271,12 +2274,6 @@ dependencies = [ ] [[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.37" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -55,7 +55,7 @@ byteorder = "1.4" cairo-rs = { version = "0.16", features=["v1_16", "png", "pdf", "ps", "svg"] } cast = "0.3.0" chrono = "0.4.0" # rsvg-convert -clap = { version = "3.2.22", features = ["cargo", "derive"] } # rsvg-convert +clap = { version = "4.0.17", 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 3a220729..54d8c958 100644 --- a/src/bin/rsvg-convert.rs +++ b/src/bin/rsvg-convert.rs @@ -786,193 +786,232 @@ fn parse_args() -> Result<Converter, Error> { 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') + .disable_version_flag(true) + .disable_help_flag(true) .arg( - clap::Arg::with_name("res_x") + clap::Arg::new("help") + .short('?') + .long("help") + .help("Display the help") + .action(clap::ArgAction::Help) + ) + .arg( + clap::Arg::new("version") + .short('v') + .long("version") + .help("Display the version information") + .action(clap::ArgAction::Version) + ) + .arg( + clap::Arg::new("res_x") .short('d') .long("dpi-x") - .takes_value(true) + .num_args(1) .value_name("number") .default_value("96") .value_parser(parse_resolution) - .help("Pixels per inch"), + .help("Pixels per inch") + .action(clap::ArgAction::Set), ) .arg( - clap::Arg::with_name("res_y") + clap::Arg::new("res_y") .short('p') .long("dpi-y") - .takes_value(true) + .num_args(1) .value_name("number") .default_value("96") .value_parser(parse_resolution) - .help("Pixels per inch"), + .help("Pixels per inch") + .action(clap::ArgAction::Set), ) .arg( - clap::Arg::with_name("zoom_x") + clap::Arg::new("zoom_x") .short('x') .long("x-zoom") - .takes_value(true) + .num_args(1) .value_name("number") .conflicts_with("zoom") .value_parser(parse_zoom_factor) - .help("Horizontal zoom factor"), + .help("Horizontal zoom factor") + .action(clap::ArgAction::Set), ) .arg( - clap::Arg::with_name("zoom_y") + clap::Arg::new("zoom_y") .short('y') .long("y-zoom") - .takes_value(true) + .num_args(1) .value_name("number") .conflicts_with("zoom") .value_parser(parse_zoom_factor) - .help("Vertical zoom factor"), + .help("Vertical zoom factor") + .action(clap::ArgAction::Set), ) .arg( - clap::Arg::with_name("zoom") + clap::Arg::new("zoom") .short('z') .long("zoom") - .takes_value(true) + .num_args(1) .value_name("number") .value_parser(parse_zoom_factor) - .help("Zoom factor"), + .help("Zoom factor") + .action(clap::ArgAction::Set), ) .arg( - clap::Arg::with_name("size_x") + clap::Arg::new("size_x") .short('w') .long("width") - .takes_value(true) + .num_args(1) .value_name("length") .value_parser(parse_length::<Horizontal, Unsigned>) - .help("Width [defaults to the width of the SVG]"), + .help("Width [defaults to the width of the SVG]") + .action(clap::ArgAction::Set), ) .arg( - clap::Arg::with_name("size_y") + clap::Arg::new("size_y") .short('h') .long("height") - .takes_value(true) + .num_args(1) .value_name("length") .value_parser(parse_length::<Vertical, Unsigned>) - .help("Height [defaults to the height of the SVG]"), + .help("Height [defaults to the height of the SVG]") + .action(clap::ArgAction::Set), ) .arg( - clap::Arg::with_name("top") + clap::Arg::new("top") .long("top") - .takes_value(true) + .num_args(1) .value_name("length") .value_parser(parse_length::<Vertical, Signed>) - .help("Distance between top edge of page and the image [defaults to 0]"), + .help("Distance between top edge of page and the image [defaults to 0]") + .action(clap::ArgAction::Set), ) .arg( - clap::Arg::with_name("left") + clap::Arg::new("left") .long("left") - .takes_value(true) + .num_args(1) .value_name("length") .value_parser(parse_length::<Horizontal, Signed>) - .help("Distance between left edge of page and the image [defaults to 0]"), + .help("Distance between left edge of page and the image [defaults to 0]") + .action(clap::ArgAction::Set), ) .arg( - clap::Arg::with_name("page_width") + clap::Arg::new("page_width") .long("page-width") - .takes_value(true) + .num_args(1) .value_name("length") .value_parser(parse_length::<Horizontal, Unsigned>) - .help("Width of output media [defaults to the width of the SVG]"), + .help("Width of output media [defaults to the width of the SVG]") + .action(clap::ArgAction::Set), ) .arg( - clap::Arg::with_name("page_height") + clap::Arg::new("page_height") .long("page-height") - .takes_value(true) + .num_args(1) .value_name("length") .value_parser(parse_length::<Vertical, Unsigned>) - .help("Height of output media [defaults to the height of the SVG]"), + .help("Height of output media [defaults to the height of the SVG]") + .action(clap::ArgAction::Set), ) .arg( - clap::Arg::with_name("format") + clap::Arg::new("format") .short('f') .long("format") - .takes_value(true) - .possible_values(supported_formats.as_slice()) + .num_args(1) + .value_parser(clap::builder::PossibleValuesParser::new(supported_formats.as_slice())) .ignore_case(true) .default_value("png") - .help("Output format"), + .help("Output format") + .action(clap::ArgAction::Set), ) .arg( - clap::Arg::with_name("output") + clap::Arg::new("output") .short('o') .long("output") - .takes_value(true) + .num_args(1) .value_parser(clap::value_parser!(PathBuf)) - .help("Output filename [defaults to stdout]"), + .help("Output filename [defaults to stdout]") + .action(clap::ArgAction::Set), ) .arg( - clap::Arg::with_name("export_id") + clap::Arg::new("export_id") .short('i') .long("export-id") - .empty_values(false) + .value_parser(clap::builder::NonEmptyStringValueParser::new()) .value_name("object id") - .help("SVG id of object to export [default is to export all objects]"), + .help("SVG id of object to export [default is to export all objects]") + .action(clap::ArgAction::Set), ) .arg( - clap::Arg::with_name("accept-language") + clap::Arg::new("accept-language") .short('l') .long("accept-language") - .empty_values(false) + .value_parser(clap::builder::NonEmptyStringValueParser::new()) .value_name("languages") - .help("Languages to accept, for example \"es-MX,de,en\" [default uses language from the environment]"), + .help("Languages to accept, for example \"es-MX,de,en\" [default uses language from the environment]") + .action(clap::ArgAction::Set), ) .arg( - clap::Arg::with_name("keep_aspect") + clap::Arg::new("keep_aspect") .short('a') .long("keep-aspect-ratio") - .help("Preserve the aspect ratio"), + .help("Preserve the aspect ratio") + .action(clap::ArgAction::SetTrue), ) .arg( - clap::Arg::with_name("background") + clap::Arg::new("background") .short('b') .long("background-color") - .takes_value(true) + .num_args(1) .value_name("color") .value_parser(clap::builder::NonEmptyStringValueParser::new()) .default_value("none") - .help("Set the background color using a CSS color spec"), + .help("Set the background color using a CSS color spec") + .action(clap::ArgAction::Set), ) .arg( - clap::Arg::with_name("stylesheet") + clap::Arg::new("stylesheet") .short('s') .long("stylesheet") - .takes_value(true) + .num_args(1) .value_parser(clap::value_parser!(PathBuf)) .value_name("filename.css") - .help("Filename of CSS stylesheet to apply"), + .help("Filename of CSS stylesheet to apply") + .action(clap::ArgAction::Set), ) .arg( - clap::Arg::with_name("unlimited") + clap::Arg::new("unlimited") .short('u') .long("unlimited") - .help("Allow huge SVG files"), + .help("Allow huge SVG files") + .action(clap::ArgAction::SetTrue), ) .arg( - clap::Arg::with_name("keep_image_data") + clap::Arg::new("keep_image_data") .long("keep-image-data") - .help("Keep image data"), + .help("Keep image data") + .conflicts_with("no_keep_image_data") + .action(clap::ArgAction::SetTrue), ) .arg( - clap::Arg::with_name("no_keep_image_data") + clap::Arg::new("no_keep_image_data") .long("no-keep-image-data") - .help("Do not keep image data"), + .help("Do not keep image data") + .conflicts_with("keep_image_data") + .action(clap::ArgAction::SetTrue), ) .arg( - clap::Arg::with_name("testing") + clap::Arg::new("testing") .long("testing") .help("Render images for librsvg's test suite") - .hidden(true), + .hide(true) + .action(clap::ArgAction::SetTrue), ) .arg( - clap::Arg::with_name("FILE") + clap::Arg::new("FILE") .value_parser(clap::value_parser!(OsString)) .help("The input file(s) to convert") - .multiple(true), + .num_args(1..) + .action(clap::ArgAction::Append), ); let matches = app.get_matches(); @@ -992,8 +1031,8 @@ fn parse_args() -> Result<Converter, Error> { }; let keep_image_data = match format { - Format::Ps | Format::Eps | Format::Pdf => !matches.contains_id("no_keep_image_data"), - _ => matches.contains_id("keep_image_data"), + Format::Ps | Format::Eps | Format::Pdf => !matches.get_flag("no_keep_image_data"), + _ => matches.get_flag("keep_image_data"), }; let language = match matches.get_one::<String>("accept-language") { @@ -1002,7 +1041,7 @@ fn parse_args() -> Result<Converter, Error> { .map(Language::AcceptLanguage) .map_err(|e| { let desc = format!("{}", e); - clap::Error::with_description(desc, clap::ErrorKind::InvalidValue) + clap::Error::raw(clap::error::ErrorKind::InvalidValue, desc) })?, }; @@ -1010,7 +1049,7 @@ fn parse_args() -> Result<Converter, Error> { .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))?; + .map_err(|e| clap::Error::raw(clap::error::ErrorKind::InvalidValue, e))?; // 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 @@ -1053,7 +1092,7 @@ fn parse_args() -> Result<Converter, Error> { 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") { + let input = match matches.get_many::<std::ffi::OsString>("FILE") { Some(values) => values .map(|f| PathOrUrl::from_os_str(f).map_err(Error)) .map(|r| r.map(Input::Named)) @@ -1089,15 +1128,15 @@ fn parse_args() -> Result<Converter, Error> { page_size, format, export_id, - keep_aspect_ratio: matches.contains_id("keep_aspect"), + keep_aspect_ratio: matches.get_flag("keep_aspect"), background_color, stylesheet: matches.get_one("stylesheet").cloned(), - unlimited: matches.contains_id("unlimited"), + unlimited: matches.get_flag("unlimited"), keep_image_data, language, input, output, - testing: matches.is_present("testing"), + testing: matches.get_flag("testing"), }) } @@ -1141,8 +1180,8 @@ impl<T> NotFound for Result<T, clap::Error> { /// arguments. fn or_none(self) -> Result<Option<T>, clap::Error> { self.map_or_else( - |e| match e.kind { - clap::ErrorKind::ArgumentNotFound => Ok(None), + |e| match e.kind() { + clap::error::ErrorKind::UnknownArgument => Ok(None), _ => Err(e), }, |v| Ok(Some(v)), |