This commit is contained in:
parent
b05bb05c48
commit
c1651ed993
3 changed files with 31 additions and 24 deletions
37
src/main.rs
37
src/main.rs
|
@ -1,27 +1,34 @@
|
|||
extern crate mpd;
|
||||
|
||||
use mpd::Client;
|
||||
use std::net::TcpStream;
|
||||
// use std::net::TcpStream;
|
||||
|
||||
use clap::Parser;
|
||||
use clap::{Parser, Subcommand};
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(version, about, long_about = None)]
|
||||
struct Args {
|
||||
#[arg(short, long)]
|
||||
name: String,
|
||||
#[arg(short, long)]
|
||||
count: u8,
|
||||
#[derive(Parser)]
|
||||
#[command(author, version, about, long_about = None)]
|
||||
#[command(propagate_version = true)]
|
||||
|
||||
struct Cli {
|
||||
#[command(subcommand)]
|
||||
command: Commands,
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
enum Commands {
|
||||
/// Adds files to myapp
|
||||
Add { name: Option<String> },
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut conn = Client::connect("localhost:6600").unwrap();
|
||||
|
||||
conn.volume(100).unwrap();
|
||||
println!("Status: {:?}", conn.status());
|
||||
conn.toggle_pause().unwrap();
|
||||
|
||||
// let args = Args::parse();
|
||||
// for _ in 0..args.count {
|
||||
// println!("Hello {}!", args.name)
|
||||
// }
|
||||
let cli = Cli::parse();
|
||||
match &cli.command {
|
||||
Commands::Add { name } => {
|
||||
println!("'myapp add' was used, name is: {:?}", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue