Skip to content

Commit

Permalink
Merge pull request #6 from oylenshpeegul/master
Browse files Browse the repository at this point in the history
Switch from structopt to clap v3 derive interface.
  • Loading branch information
dbaynard authored Jul 1, 2022
2 parents 0ccd8f0 + e3b369e commit ca54ccf
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 83 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
152 changes: 82 additions & 70 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "booklet"
version = "0.1.2"
version = "0.1.3"
authors = ["David Baynard <rust@baynard.dev>"]
description = "Rearrange pdf pages for booklet printing"
homepage = "https://github.com/dbaynard/booklet"
Expand All @@ -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"
21 changes: 11 additions & 10 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,

/// Output file, if present (otherwise stdout)
output: Option<String>,
}

0 comments on commit ca54ccf

Please sign in to comment.