uriplaylistbin: Port example from structopt to clap

This commit is contained in:
Sebastian Dröge 2022-09-27 13:30:38 +03:00
parent 38753b08ac
commit 7479888200
2 changed files with 8 additions and 6 deletions

View file

@ -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" }

View file

@ -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<String>,
}
@ -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");
}