Parse command-line arguments with clap
This commit is contained in:
parent
ac1d05089d
commit
f3b5bfe6f4
2 changed files with 20 additions and 2 deletions
|
@ -5,4 +5,5 @@ edition = "2021"
|
|||
license = "GPL-3.0-or-later"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.0.18", features = ["derive"] }
|
||||
rodio = "0.16.0"
|
||||
|
|
21
src/main.rs
21
src/main.rs
|
@ -1,3 +1,4 @@
|
|||
use clap::Parser;
|
||||
|
||||
fn play_file(file: &str) {
|
||||
use rodio::{Decoder, OutputStream, source::Source};
|
||||
|
@ -9,6 +10,22 @@ fn play_file(file: &str) {
|
|||
std::thread::sleep(std::time::Duration::from_secs(5));
|
||||
}
|
||||
|
||||
fn main() {
|
||||
play_file("test.flac");
|
||||
// https://github.com/UoC-Radio/audio-scheduler/blob/45275818423220de90b4ae578b57acdc138e5f50/main.c#L33-L63
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(version)]
|
||||
struct Args {
|
||||
#[arg(short='s', long)]
|
||||
audio_sink_bin: String,
|
||||
#[arg(short='d', long)]
|
||||
debug_level: u8,
|
||||
#[arg(short='m', long)]
|
||||
debug_mask: u8,
|
||||
#[arg(short='p', long)]
|
||||
port: u32,
|
||||
config_file: String,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// play_file("test.flac");
|
||||
let _args = Args::parse();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue