From 717f39dd404ca69c86e6e75083151ecd19aab806 Mon Sep 17 00:00:00 2001 From: Alex Butler Date: Thu, 20 Oct 2022 16:47:56 +0100 Subject: [PATCH] Update to clap 4 (#52) * Update to clap 4 * Test completions in release mode * Remove clap already-default features * cargo update * Update print-completions --release note * Move print-completions ci to separate flow --- .github/workflows/ci.yml | 17 +++- CHANGELOG.md | 3 + Cargo.lock | 141 +++++++++++++++++-------------- Cargo.toml | 4 +- src/command/args.rs | 12 +-- src/command/args/encode.rs | 22 ++--- src/command/args/vmaf.rs | 4 +- src/command/crf_search.rs | 12 +-- src/command/encode.rs | 2 +- src/command/print_completions.rs | 11 +-- src/command/sample_encode.rs | 8 +- src/command/vmaf.rs | 6 +- src/main.rs | 2 +- 13 files changed, 133 insertions(+), 111 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4f4cad2..1c8bc57 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,10 +15,19 @@ jobs: - run: rustup update stable - uses: actions/checkout@v2 - run: cargo test --locked - # check print-completions don't fail - - run: cargo run -- print-completions bash - - run: cargo run -- print-completions fish - - run: cargo run -- print-completions zsh + + # check print-completions don't fail + print-completions: + runs-on: ubuntu-latest + env: + RUST_BACKTRACE: 1 + steps: + - run: rustup update stable + - uses: actions/checkout@v2 + # Note: Using --release as clap debug-asserts panic + - run: cargo run --release --locked -- print-completions bash + - run: cargo run --release --locked -- print-completions fish + - run: cargo run --release --locked -- print-completions zsh test-windows: runs-on: windows-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index 93d1be4..81c53b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# Unreleased (v0.4.4) +* Update to clap v4 which changes help/about output & reduces binary size. + # v0.4.3 * Fix terminal breaking sometimes after exitting early. diff --git a/Cargo.lock b/Cargo.lock index 33130d2..751f81d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -75,35 +75,34 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "3.2.22" +version = "4.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86447ad904c7fb335a790c9d7fe3d0d971dc523b8ccd1561a520de9a85302750" +checksum = "06badb543e734a2d6568e19a40af66ed5364360b9226184926f89d229b4b4267" dependencies = [ "atty", "bitflags", "clap_derive", "clap_lex", - "indexmap", "once_cell", "strsim", "termcolor", - "textwrap", + "terminal_size 0.2.1", ] [[package]] name = "clap_complete" -version = "3.2.5" +version = "4.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f7a2e0a962c45ce25afce14220bc24f9dade0a1787f185cecf96bfba7847cd8" +checksum = "dfe581a2035db4174cdbdc91265e1aba50f381577f0510d0ad36c7bc59cc84a3" dependencies = [ "clap", ] [[package]] name = "clap_derive" -version = "3.2.18" +version = "4.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65" +checksum = "c42f169caba89a7d512b5418b09864543eeb4d497416c917d7137863bd2076ad" dependencies = [ "heck", "proc-macro-error", @@ -114,9 +113,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", ] @@ -130,7 +129,7 @@ dependencies = [ "encode_unicode", "libc", "once_cell", - "terminal_size", + "terminal_size 0.1.17", "unicode-width", "winapi", ] @@ -174,9 +173,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f21eda599937fba36daeb58a22e8f5cee2d14c4a17b5b7739c7c8e5e3b8230c" +checksum = "38390104763dc37a5145a53c29c63c1290b5d316d6086ec32c293f6736051bb0" dependencies = [ "futures-channel", "futures-core", @@ -189,9 +188,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30bdd20c28fadd505d0fd6712cdfcb0d4b5648baf45faef7f852afb2399bb050" +checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed" dependencies = [ "futures-core", "futures-sink", @@ -199,15 +198,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e5aa3de05362c3fb88de6531e6296e85cde7739cccad4b9dfeeb7f6ebce56bf" +checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" [[package]] name = "futures-executor" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ff63c23854bee61b6e9cd331d523909f238fc7636290b96826e9cfa5faa00ab" +checksum = "7acc85df6714c176ab5edf386123fafe217be88c0840ec11f199441134a074e2" dependencies = [ "futures-core", "futures-task", @@ -216,15 +215,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbf4d2a7a308fd4578637c0b17c7e1c7ba127b8f6ba00b29f717e9655d85eb68" +checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb" [[package]] name = "futures-macro" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42cd15d1c7456c04dbdf7e88bcd69760d74f3a798d6444e16974b505b0e62f17" +checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d" dependencies = [ "proc-macro2", "quote", @@ -233,21 +232,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b20ba5a92e727ba30e72834706623d94ac93a725410b6a6b6fbc1b07f7ba56" +checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9" [[package]] name = "futures-task" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6508c467c73851293f390476d4491cf4d227dbabcd4170f3bb6044959b294f1" +checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" [[package]] name = "futures-util" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44fb6cb1be61cc1d2e43b262516aafcf63b241cffdb1d3fa115f91d9c7b09c90" +checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" dependencies = [ "futures-channel", "futures-core", @@ -272,12 +271,6 @@ dependencies = [ "wasi", ] -[[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" @@ -299,16 +292,6 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" -[[package]] -name = "indexmap" -version = "1.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" -dependencies = [ - "autocfg", - "hashbrown", -] - [[package]] name = "indicatif" version = "0.17.1" @@ -320,17 +303,29 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "io-lifetimes" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ea37f355c05dde75b84bba2d767906ad522e97cd9e2eef2be7a4ab7fb442c06" + [[package]] name = "itoa" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754" +checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" [[package]] name = "libc" -version = "0.2.134" +version = "0.2.135" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68783febc7782c6c5cb401fbda4de5a9898be1762314da0bb2c10ced61f18b0c" + +[[package]] +name = "linux-raw-sys" +version = "0.0.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "329c933548736bc49fd575ee68c89e8be4d260064184389a5b77517cddd99ffb" +checksum = "d4d2456c373231a208ad294c33dc5bff30051eafd954cd4caae83a712b12854d" [[package]] name = "log" @@ -440,9 +435,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.46" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94e2ef8dbfc347b10c094890f778ee2e36ca9bb4262e86dc99cd217e35f3470b" +checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" dependencies = [ "unicode-ident", ] @@ -486,6 +481,20 @@ dependencies = [ "getrandom", ] +[[package]] +name = "rustix" +version = "0.35.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbb2fda4666def1433b1b05431ab402e42a1084285477222b72d6c564c417cef" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys", +] + [[package]] name = "ryu" version = "1.0.11" @@ -514,9 +523,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.85" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e55a28e3aaef9d5ce0506d0a14dbba8054ddc7e499ef522dd8b26859ec9d4a44" +checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45" dependencies = [ "itoa", "ryu", @@ -555,9 +564,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "1.0.101" +version = "1.0.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e90cde112c4b9690b8cbe810cba9ddd8bc1d7472e2cae317b69e9438c1cba7d2" +checksum = "3fcd952facd492f9be3ef0d0b7032a6e442ee9b361d4acc2b1d0c4aaa5f613a1" dependencies = [ "proc-macro2", "quote", @@ -584,16 +593,20 @@ dependencies = [ ] [[package]] -name = "textwrap" -version = "0.15.1" +name = "terminal_size" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "949517c0cf1bf4ee812e2e07e08ab448e3ae0d23472aee8a06c985f0c8815b16" +checksum = "8440c860cf79def6164e4a0a983bcc2305d82419177a0e0c71930d049e3ac5a1" +dependencies = [ + "rustix", + "windows-sys", +] [[package]] name = "time" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c3f9a28b618c3a6b9251b6908e9c99e04b9e5c02e6581ccbb67d59c34ef7f9b" +checksum = "d634a985c4d4238ec39cacaed2e7ae552fbd3c476b552c1deac3021b7d7eaf0c" dependencies = [ "libc", "num_threads", @@ -652,9 +665,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6edf2d6bc038a43d31353570e27270603f4648d18f5ed10c0e179abe43255af" +checksum = "d660770404473ccd7bc9f8b28494a811bc18542b915c0855c51e8f419d5223ce" dependencies = [ "futures-core", "pin-project-lite", @@ -676,9 +689,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd" +checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" [[package]] name = "unicode-width" diff --git a/Cargo.toml b/Cargo.toml index 8222007..d64dcf1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,8 +11,8 @@ readme = "README.md" [dependencies] anyhow = "1.0.53" -clap = { version = "3.2", features = ["derive", "env"] } -clap_complete = "3.2" +clap = { version = "4", features = ["derive", "env", "wrap_help"] } +clap_complete = "4" console = "=0.15.1" # no lazy_static ffprobe = "0.3" futures = "0.3.19" diff --git a/src/command/args.rs b/src/command/args.rs index c220874..50e66e4 100644 --- a/src/command/args.rs +++ b/src/command/args.rs @@ -14,7 +14,7 @@ pub struct EncodeToOutput { /// Output file, by default the same as input with `.av1` before the extension. /// /// E.g. if unspecified: -i vid.mp4 --> vid.av1.mp4 - #[clap(short, long, value_parser)] + #[arg(short, long)] pub output: Option, /// Set the output ffmpeg audio codec. @@ -22,14 +22,14 @@ pub struct EncodeToOutput { /// otherwise 'libopus'. /// /// See https://ffmpeg.org/ffmpeg.html#Audio-Options. - #[clap(long = "acodec", value_parser)] + #[arg(long = "acodec")] pub audio_codec: Option, /// Downmix input audio streams to stereo if input streams use greater than /// 3 channels. /// /// No effect if the input audio has 3 or fewer channels. - #[clap(long, value_parser)] + #[arg(long)] pub downmix_to_stereo: bool, } @@ -38,7 +38,7 @@ pub struct EncodeToOutput { pub struct Sample { /// Number of 20s samples to use across the input video. Overrides --sample-every. /// More samples take longer but may provide a more accurate result. - #[clap(long, value_parser)] + #[arg(long)] pub samples: Option, /// Calculate number of samples by dividing the input duration by this value. @@ -46,12 +46,12 @@ pub struct Sample { /// More samples take longer but may provide a more accurate result. /// /// Setting --samples overrides this value. - #[clap(long, default_value = "12m", value_parser = humantime::parse_duration)] + #[arg(long, default_value = "12m", value_parser = humantime::parse_duration)] pub sample_every: Duration, /// Directory to store temporary sample data in. /// Defaults to using the input's directory. - #[clap(long, env = "AB_AV1_TEMP_DIR", value_parser)] + #[arg(long, env = "AB_AV1_TEMP_DIR")] pub temp_dir: Option, } diff --git a/src/command/args/encode.rs b/src/command/args/encode.rs index fc70cd0..1f422a8 100644 --- a/src/command/args/encode.rs +++ b/src/command/args/encode.rs @@ -19,22 +19,22 @@ pub struct Encode { /// Encoder override. See https://ffmpeg.org/ffmpeg-all.html#toc-Video-Encoders. /// /// [possible values: svt-av1, libx264, libx265, libvpx-vp9, ...] - #[clap(arg_enum, short, long, value_parser, default_value = "svt-av1")] + #[arg(value_enum, short, long, default_value = "svt-av1")] pub encoder: Encoder, /// Input video file. - #[clap(short, long, value_parser)] + #[arg(short, long)] pub input: PathBuf, /// Ffmpeg video filter applied to the input before av1 encoding. /// E.g. --vfilter "scale=1280:-1,fps=24". /// /// See https://ffmpeg.org/ffmpeg-filters.html#Video-Filters - #[clap(long, value_parser)] + #[arg(long)] pub vfilter: Option, /// Pixel format. svt-av1 default yuv420p10le. - #[clap(arg_enum, long, value_parser)] + #[arg(value_enum, long)] pub pix_format: Option, /// Encoder preset (0-13). @@ -44,7 +44,7 @@ pub struct Encode { /// libaom-av1 preset is mapped to equivalent -cpu-used argument. /// /// [svt-av1 default: 8] - #[clap(long, value_parser)] + #[arg(long)] pub preset: Option, /// Interval between keyframes. Can be specified as a number of frames, or a duration. @@ -54,18 +54,18 @@ pub struct Encode { /// Durations will be converted to frames using the input fps. /// /// Works on svt-av1 & most ffmpeg encoders set with --encoder. - #[clap(long, value_parser)] + #[arg(long)] pub keyint: Option, /// Svt-av1 scene change detection, inserts keyframes at scene changes. /// Defaults on if using default keyint & the input duration is over 3m. Otherwise off. - #[clap(long, value_parser)] + #[arg(long)] pub scd: Option, /// Additional svt-av1 arg(s). E.g. --svt mbr=2000 --svt film-grain=30 /// /// See https://gitlab.com/AOMediaCodec/SVT-AV1/-/blob/master/Docs/svt-av1_encoder_user_guide.md#options - #[clap(long = "svt", value_parser = parse_svt_arg)] + #[arg(long = "svt", value_parser = parse_svt_arg)] pub svt_args: Vec>, /// Additional ffmpeg encoder arg(s). E.g. `--enc x265-params=lossless=1` @@ -73,14 +73,14 @@ pub struct Encode { /// /// The first '=' symbol will be used to infer that this is an option with a value. /// Passed to ffmpeg like "x265-params=lossless=1" -> ['-x265-params', 'lossless=1'] - #[clap(long = "enc", allow_hyphen_values = true, value_parser = parse_enc_arg)] + #[arg(long = "enc", allow_hyphen_values = true, value_parser = parse_enc_arg)] pub enc_args: Vec, /// Additional ffmpeg input encoder arg(s). E.g. `--enc-input r=1` /// These are added as ffmpeg input file options. /// /// See --enc docs. - #[clap(long = "enc-input", allow_hyphen_values = true, value_parser = parse_enc_arg)] + #[arg(long = "enc-input", allow_hyphen_values = true, value_parser = parse_enc_arg)] pub enc_input_args: Vec, } @@ -455,7 +455,7 @@ impl std::str::FromStr for KeyInterval { } } -#[derive(clap::ArgEnum, Clone, Copy, Debug, PartialEq, Eq)] +#[derive(clap::ValueEnum, Clone, Copy, Debug, PartialEq, Eq)] #[clap(rename_all = "lower")] pub enum PixelFormat { Yuv420p10le, diff --git a/src/command/args/vmaf.rs b/src/command/args/vmaf.rs index f6c0ba5..1df75e5 100644 --- a/src/command/args/vmaf.rs +++ b/src/command/args/vmaf.rs @@ -8,7 +8,7 @@ pub struct Vmaf { /// Additional vmaf arg(s). E.g. --vmaf n_threads=8 --vmaf n_subsample=4 /// /// See https://ffmpeg.org/ffmpeg-filters.html#libvmaf. - #[clap(long = "vmaf", value_parser = parse_vmaf_arg)] + #[arg(long = "vmaf", value_parser = parse_vmaf_arg)] pub vmaf_args: Vec>, /// Video resolution scale to use in VMAF analysis. If set, video streams will be bicupic @@ -23,7 +23,7 @@ pub struct Vmaf { /// are less than 3456 & 1944 respectively upscale to 4k. Otherwise no scaling. /// /// Scaling happens after any input/reference vfilters. - #[clap(long, default_value_t = VmafScale::Auto, value_parser = parse_vmaf_scale)] + #[arg(long, default_value_t = VmafScale::Auto, value_parser = parse_vmaf_scale)] pub vmaf_scale: VmafScale, } diff --git a/src/command/crf_search.rs b/src/command/crf_search.rs index dc47017..b088e65 100644 --- a/src/command/crf_search.rs +++ b/src/command/crf_search.rs @@ -29,25 +29,25 @@ pub struct Args { pub args: args::Encode, /// Desired min VMAF score to deliver. - #[clap(long, value_parser, default_value_t = 95.0)] + #[arg(long, default_value_t = 95.0)] pub min_vmaf: f32, /// Maximum desired encoded size percentage of the input size. - #[clap(long, value_parser, default_value_t = 80.0)] + #[arg(long, default_value_t = 80.0)] pub max_encoded_percent: f32, /// Minimum (highest quality) crf value to try. - #[clap(long, value_parser, default_value_t = 10)] + #[arg(long, default_value_t = 10)] pub min_crf: u8, /// Maximum (lowest quality) crf value to try. - #[clap(long, value_parser, default_value_t = 55)] + #[arg(long, default_value_t = 55)] pub max_crf: u8, #[clap(flatten)] pub sample: args::Sample, - #[clap(skip)] + #[arg(skip)] pub quiet: bool, #[clap(flatten)] @@ -232,7 +232,7 @@ impl Sample { } } -#[derive(Debug, Clone, Copy, clap::ArgEnum)] +#[derive(Debug, Clone, Copy, clap::ValueEnum)] pub enum StdoutFormat { Human, } diff --git a/src/command/encode.rs b/src/command/encode.rs index f145ecf..e67d72c 100644 --- a/src/command/encode.rs +++ b/src/command/encode.rs @@ -23,7 +23,7 @@ pub struct Args { pub args: args::Encode, /// Encoder constant rate factor (1-63). Lower means better quality. - #[clap(long, value_parser)] + #[arg(long)] pub crf: u8, #[clap(flatten)] diff --git a/src/command/print_completions.rs b/src/command/print_completions.rs index ac6c8df..2049865 100644 --- a/src/command/print_completions.rs +++ b/src/command/print_completions.rs @@ -1,20 +1,17 @@ -use anyhow::anyhow; -use clap::{IntoApp, Parser}; +use clap::{CommandFactory, Parser}; use clap_complete::Shell; -use std::str::FromStr; /// Print shell completions. #[derive(Parser)] - pub struct Args { /// Shell. - #[clap(value_parser, default_value = "bash")] - shell: String, + #[arg(value_enum, default_value_t = Shell::Bash)] + shell: Shell, } pub fn print_completions(Args { shell }: Args) -> anyhow::Result<()> { clap_complete::generate( - Shell::from_str(&shell).map_err(|e| anyhow!("Shell {e}"))?, + shell, &mut crate::Command::command(), "ab-av1", &mut std::io::stdout(), diff --git a/src/command/sample_encode.rs b/src/command/sample_encode.rs index 86b07ab..ffec5c2 100644 --- a/src/command/sample_encode.rs +++ b/src/command/sample_encode.rs @@ -39,18 +39,18 @@ pub struct Args { pub svt: args::Encode, /// Encoder constant rate factor (1-63). Lower means better quality. - #[clap(value_parser, long)] + #[arg(long)] pub crf: u8, #[clap(flatten)] pub sample: args::Sample, /// Keep temporary files after exiting. - #[clap(long, value_parser)] + #[arg(long)] pub keep: bool, /// Stdout message format `human` or `json`. - #[clap(long, value_parser, arg_enum, default_value_t = StdoutFormat::Human)] + #[arg(long, value_enum, default_value_t = StdoutFormat::Human)] pub stdout_format: StdoutFormat, #[clap(flatten)] @@ -335,7 +335,7 @@ impl EncodeResults for Vec { } } -#[derive(Debug, Clone, Copy, clap::ArgEnum)] +#[derive(Debug, Clone, Copy, clap::ValueEnum)] pub enum StdoutFormat { Human, Json, diff --git a/src/command/vmaf.rs b/src/command/vmaf.rs index 9c8b2c9..b07909b 100644 --- a/src/command/vmaf.rs +++ b/src/command/vmaf.rs @@ -17,16 +17,16 @@ use tokio_stream::StreamExt; #[derive(Parser)] pub struct Args { /// Reference video file. - #[clap(long, value_parser)] + #[arg(long)] pub reference: PathBuf, /// Ffmpeg video filter applied to the reference before analysis. /// E.g. --vfilter "scale=1280:-1,fps=24". - #[clap(long, value_parser)] + #[arg(long)] pub reference_vfilter: Option, /// Re-encoded/distorted video file. - #[clap(long, value_parser)] + #[arg(long)] pub distorted: PathBuf, #[clap(flatten)] diff --git a/src/main.rs b/src/main.rs index 6269c54..c83bcc1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,7 +19,7 @@ const SAMPLE_SIZE_S: u64 = 20; const SAMPLE_SIZE: Duration = Duration::from_secs(SAMPLE_SIZE_S); #[derive(Parser)] -#[clap(version, about)] +#[command(version, about)] enum Command { SampleEncode(command::sample_encode::Args), Vmaf(command::vmaf::Args),