From 925600aeb2be90c0e84ee0e81529c0f755da9453 Mon Sep 17 00:00:00 2001 From: Tim Heaney Date: Fri, 1 Jul 2022 14:56:59 -0400 Subject: [PATCH 1/4] Switch cli dependency to clap from structopt --- Cargo.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1815903..022f25d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,12 +13,11 @@ name = "pdfbooklet" path = "src/main.rs" [dependencies] +clap = { version = "3.2.8", features = ["derive"] } lopdf = "0.27.0" num = "0.4.0" num-derive = "0.3.3" num-traits = "0.2.15" -structopt = "0.3.26" -structopt-derive = "0.4.18" [dev-dependencies] quickcheck = "1.0.3" From b3ba57c4fa16ef6174e0a44c3866468def1497ff Mon Sep 17 00:00:00 2001 From: David Baynard Date: Fri, 1 Jul 2022 23:01:21 +0100 Subject: [PATCH 2/4] Update cargo.lock --- Cargo.lock | 152 +++++++++++++++++++++++++++++------------------------ 1 file changed, 82 insertions(+), 70 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3149e5a..a4042db 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,15 +17,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi", -] - [[package]] name = "atty" version = "0.2.14" @@ -57,15 +48,14 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "booklet" -version = "0.1.2" +version = "0.1.3" dependencies = [ + "clap", "lopdf", "num", "num-derive", "num-traits", "quickcheck", - "structopt", - "structopt-derive", ] [[package]] @@ -95,17 +85,41 @@ dependencies = [ [[package]] name = "clap" -version = "2.34.0" +version = "3.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +checksum = "190814073e85d238f31ff738fcb0bf6910cedeb73376c87cd69291028966fd83" dependencies = [ - "ansi_term", "atty", "bitflags", + "clap_derive", + "clap_lex", + "indexmap", + "once_cell", "strsim", + "termcolor", "textwrap", - "unicode-width", - "vec_map", +] + +[[package]] +name = "clap_derive" +version = "3.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "759bf187376e1afa7b85b959e6a664a3e7a95203415dba952ad19139e798f902" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[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]] @@ -230,14 +244,17 @@ dependencies = [ "wasi 0.11.0+wasi-snapshot-preview1", ] +[[package]] +name = "hashbrown" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db0d4cf898abf0081f964436dc980e96670a0f36863e4b83aaacdb65c9d7ccc3" + [[package]] name = "heck" -version = "0.3.3" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" -dependencies = [ - "unicode-segmentation", -] +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" [[package]] name = "hermit-abi" @@ -248,6 +265,16 @@ dependencies = [ "libc", ] +[[package]] +name = "indexmap" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" +dependencies = [ + "autocfg", + "hashbrown", +] + [[package]] name = "itoa" version = "0.4.8" @@ -408,6 +435,18 @@ dependencies = [ "autocfg", ] +[[package]] +name = "once_cell" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225" + +[[package]] +name = "os_str_bytes" +version = "6.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21326818e99cfe6ce1e524c2a805c189a99b5ae555a35d19f9a284b427d86afa" + [[package]] name = "pom" version = "3.2.0" @@ -641,33 +680,9 @@ checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" [[package]] name = "strsim" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - -[[package]] -name = "structopt" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" -dependencies = [ - "clap", - "lazy_static", - "structopt-derive", -] - -[[package]] -name = "structopt-derive" -version = "0.4.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" -dependencies = [ - "heck", - "proc-macro-error", - "proc-macro2", - "quote", - "syn", -] +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" @@ -681,14 +696,20 @@ dependencies = [ ] [[package]] -name = "textwrap" -version = "0.11.0" +name = "termcolor" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" dependencies = [ - "unicode-width", + "winapi-util", ] +[[package]] +name = "textwrap" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" + [[package]] name = "time" version = "0.1.44" @@ -744,24 +765,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c" -[[package]] -name = "unicode-segmentation" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" - -[[package]] -name = "unicode-width" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" - -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "version_check" version = "0.9.4" @@ -856,6 +859,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" From 58496092760a5c90a491b34478bcf0e6415e2eae Mon Sep 17 00:00:00 2001 From: Tim Heaney Date: Fri, 1 Jul 2022 14:56:59 -0400 Subject: [PATCH 3/4] Switch from structopt to clap v3 derive interface. --- src/main.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/main.rs b/src/main.rs index e21654d..029bf98 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,32 +2,33 @@ extern crate booklet; use booklet::*; -/// Argument parsing uses `structopt` -extern crate structopt; -extern crate structopt_derive; -use structopt::StructOpt; +/// Argument parsing uses `clap` version 3 with its derive interface. +extern crate clap; +use clap::Parser; /// # Main functions fn main() { - let opt = Opt::from_args(); + let args = Args::parse(); - match booklet(opt) { + match booklet(args) { Ok(_) => (), Err(e) => println!("{}", e), } } -fn booklet(opt: Opt) -> lopdf::Result<()> { - reorder(opt.input, opt.output)?; +fn booklet(args: Args) -> lopdf::Result<()> { + reorder(args.input, args.output)?; Ok(()) } /// # Options -#[derive(StructOpt)] -struct Opt { +#[derive(Parser)] +#[clap(author, version, about, long_about = None)] +struct Args { /// Input file, if present (otherwise stdin) input: Option, + /// Output file, if present (otherwise stdout) output: Option, } From e3b369e432e6d846f03607df4aa83a0d3e88410e Mon Sep 17 00:00:00 2001 From: Tim Heaney Date: Fri, 1 Jul 2022 14:56:59 -0400 Subject: [PATCH 4/4] Bump version to 0.1.3 --- CHANGELOG.md | 5 +++++ Cargo.toml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f891c1..1214851 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## [0.1.3] — 2022-07-01 + +- Switch from structopt to clap — thanks @oylenshpeegul + ## [0.1.2] — 2022-06-30 - Upgrades dependencies — thanks @nikolaiwarner @@ -13,6 +17,7 @@ - Initial version +[0.1.3]: https://github.com/dbaynard/booklet/compare/0.1.2...0.1.3 [0.1.2]: https://github.com/dbaynard/booklet/compare/0.1.1...0.1.2 [0.1.1]: https://github.com/dbaynard/booklet/compare/0.1.0...0.1.1 [0.1.0]: https://github.com/dbaynard/booklet/tree/0.1.0 diff --git a/Cargo.toml b/Cargo.toml index 022f25d..fd962ba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "booklet" -version = "0.1.2" +version = "0.1.3" authors = ["David Baynard "] description = "Rearrange pdf pages for booklet printing" homepage = "https://github.com/dbaynard/booklet"