diff --git a/Cargo.toml b/Cargo.toml index bb0e35f..879caea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ thiserror = "1.0.2" anyhow = "1.0.12" hound = "3.4" ringbuf = "0.2" -clap = { version = "2.33.3", default-features = false } +clap = { version = "3", default-features = false, features = ["std"] } [target.'cfg(target_os = "windows")'.dependencies] winapi = { version = "0.3", features = ["audiosessiontypes", "audioclient", "coml2api", "combaseapi", "debug", "devpkey", "handleapi", "ksmedia", "mmdeviceapi", "objbase", "profileapi", "std", "synchapi", "winbase", "winuser"] } diff --git a/examples/beep.rs b/examples/beep.rs index ed15204..92716c8 100644 --- a/examples/beep.rs +++ b/examples/beep.rs @@ -2,6 +2,7 @@ extern crate anyhow; extern crate clap; extern crate cpal; +use clap::arg; use cpal::traits::{DeviceTrait, HostTrait, StreamTrait}; #[derive(Debug)] @@ -17,12 +18,12 @@ struct Opt { impl Opt { fn from_args() -> Self { - let app = clap::App::new("beep").arg_from_usage("[DEVICE] 'The audio device to use'"); + let app = clap::App::new("beep").arg(arg!([DEVICE] "The audio device to use")); #[cfg(all( any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"), feature = "jack" ))] - let app = app.arg_from_usage("-j, --jack 'Use the JACK host"); + let app = app.arg(arg!(-j --jack "Use the JACK host")); let matches = app.get_matches(); let device = matches.value_of("DEVICE").unwrap_or("default").to_string(); diff --git a/examples/feedback.rs b/examples/feedback.rs index f0656b6..548ba3d 100644 --- a/examples/feedback.rs +++ b/examples/feedback.rs @@ -12,6 +12,7 @@ extern crate cpal; extern crate ringbuf; use anyhow::Context; +use clap::arg; use cpal::traits::{DeviceTrait, HostTrait, StreamTrait}; use ringbuf::RingBuffer; @@ -31,17 +32,16 @@ struct Opt { impl Opt { fn from_args() -> anyhow::Result { let app = clap::App::new("beep") - .arg_from_usage( - "-l, --latency [DELAY_MS] 'Specify the delay between input and output [default: 150]'", - ) - .arg_from_usage("[IN] 'The input audio device to use'") - .arg_from_usage("[OUT] 'The output audio device to use'"); + .arg(arg!( + -l --latency [DELAY_MS] "Specify the delay between input and output [default: 150]")) + .arg(arg!([IN] "The input audio device to use")) + .arg(arg!([OUT] "The output audio device to use")); #[cfg(all( any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"), feature = "jack" ))] - let app = app.arg_from_usage("-j, --jack 'Use the JACK host"); + let app = app.arg(arg!(-j --jack "Use the JACK host")); let matches = app.get_matches(); let latency: f32 = matches .value_of("latency") diff --git a/examples/record_wav.rs b/examples/record_wav.rs index 15016f3..767bfa1 100644 --- a/examples/record_wav.rs +++ b/examples/record_wav.rs @@ -7,6 +7,7 @@ extern crate clap; extern crate cpal; extern crate hound; +use clap::arg; use cpal::traits::{DeviceTrait, HostTrait, StreamTrait}; use std::fs::File; use std::io::BufWriter; @@ -25,12 +26,12 @@ struct Opt { impl Opt { fn from_args() -> Self { - let app = clap::App::new("beep").arg_from_usage("[DEVICE] 'The audio device to use'"); + let app = clap::App::new("beep").arg(arg!([DEVICE] "The audio device to use")); #[cfg(all( any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"), feature = "jack" ))] - let app = app.arg_from_usage("-j, --jack 'Use the JACK host"); + let app = app.arg(arg!(-j --jack "Use the JACK host")); let matches = app.get_matches(); let device = matches.value_of("DEVICE").unwrap_or("default").to_string();