From 7479888200382e23891bdd913b2d9dbcc453189b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 27 Sep 2022 13:30:38 +0300 Subject: [PATCH] uriplaylistbin: Port example from structopt to clap --- utils/uriplaylistbin/Cargo.toml | 3 ++- utils/uriplaylistbin/examples/playlist.rs | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/utils/uriplaylistbin/Cargo.toml b/utils/uriplaylistbin/Cargo.toml index eada0e9e..ded337ca 100644 --- a/utils/uriplaylistbin/Cargo.toml +++ b/utils/uriplaylistbin/Cargo.toml @@ -12,10 +12,10 @@ rust-version = "1.63" gst = { package = "gstreamer", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" } once_cell = "1.0" anyhow = "1" +clap = { version = "3.2", optional = true, features = ["derive"] } [dev-dependencies] gst-app = { package = "gstreamer-app", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" } -structopt = "0.3" url = "2.2" more-asserts = "0.3" @@ -27,6 +27,7 @@ path = "src/lib.rs" [[example]] name = "playlist" path = "examples/playlist.rs" +required-features = ["clap"] [build-dependencies] gst-plugin-version-helper = { path="../../version-helper" } diff --git a/utils/uriplaylistbin/examples/playlist.rs b/utils/uriplaylistbin/examples/playlist.rs index df8cb6bc..fdbf779f 100644 --- a/utils/uriplaylistbin/examples/playlist.rs +++ b/utils/uriplaylistbin/examples/playlist.rs @@ -12,13 +12,14 @@ use std::{ sync::{Arc, Mutex}, }; +use clap::Parser; use gst::prelude::*; -use structopt::StructOpt; -#[derive(Debug, StructOpt)] -#[structopt(name = "playlist", about = "An example of uriplaylistbin usage.")] +#[derive(Debug, Parser)] +#[clap(version, author)] +#[clap(about = "An example of uriplaylistbin usage.")] struct Opt { - #[structopt(default_value = "1", short = "i", long = "iterations")] + #[clap(short, default_value = "1", action)] iterations: u32, uris: Vec, } @@ -82,7 +83,7 @@ fn main() -> anyhow::Result<()> { gst::init().unwrap(); gsturiplaylistbin::plugin_register_static().expect("Failed to register uriplaylistbin plugin"); - let opt = Opt::from_args(); + let opt = Opt::parse(); if opt.uris.is_empty() { anyhow::bail!("Need at least one URI to play"); }