mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-29 15:01:07 +00:00
uriplaylistbin: Port example from structopt to clap
This commit is contained in:
parent
38753b08ac
commit
7479888200
2 changed files with 8 additions and 6 deletions
|
@ -12,10 +12,10 @@ rust-version = "1.63"
|
||||||
gst = { package = "gstreamer", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
|
gst = { package = "gstreamer", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
|
||||||
once_cell = "1.0"
|
once_cell = "1.0"
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
|
clap = { version = "3.2", optional = true, features = ["derive"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
gst-app = { package = "gstreamer-app", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
|
gst-app = { package = "gstreamer-app", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
|
||||||
structopt = "0.3"
|
|
||||||
url = "2.2"
|
url = "2.2"
|
||||||
more-asserts = "0.3"
|
more-asserts = "0.3"
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ path = "src/lib.rs"
|
||||||
[[example]]
|
[[example]]
|
||||||
name = "playlist"
|
name = "playlist"
|
||||||
path = "examples/playlist.rs"
|
path = "examples/playlist.rs"
|
||||||
|
required-features = ["clap"]
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
gst-plugin-version-helper = { path="../../version-helper" }
|
gst-plugin-version-helper = { path="../../version-helper" }
|
||||||
|
|
|
@ -12,13 +12,14 @@ use std::{
|
||||||
sync::{Arc, Mutex},
|
sync::{Arc, Mutex},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use clap::Parser;
|
||||||
use gst::prelude::*;
|
use gst::prelude::*;
|
||||||
use structopt::StructOpt;
|
|
||||||
|
|
||||||
#[derive(Debug, StructOpt)]
|
#[derive(Debug, Parser)]
|
||||||
#[structopt(name = "playlist", about = "An example of uriplaylistbin usage.")]
|
#[clap(version, author)]
|
||||||
|
#[clap(about = "An example of uriplaylistbin usage.")]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[structopt(default_value = "1", short = "i", long = "iterations")]
|
#[clap(short, default_value = "1", action)]
|
||||||
iterations: u32,
|
iterations: u32,
|
||||||
uris: Vec<String>,
|
uris: Vec<String>,
|
||||||
}
|
}
|
||||||
|
@ -82,7 +83,7 @@ fn main() -> anyhow::Result<()> {
|
||||||
gst::init().unwrap();
|
gst::init().unwrap();
|
||||||
gsturiplaylistbin::plugin_register_static().expect("Failed to register uriplaylistbin plugin");
|
gsturiplaylistbin::plugin_register_static().expect("Failed to register uriplaylistbin plugin");
|
||||||
|
|
||||||
let opt = Opt::from_args();
|
let opt = Opt::parse();
|
||||||
if opt.uris.is_empty() {
|
if opt.uris.is_empty() {
|
||||||
anyhow::bail!("Need at least one URI to play");
|
anyhow::bail!("Need at least one URI to play");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue