mirror of
https://github.com/figsoda/mmtc
synced 2025-02-16 21:38:38 +00:00
migrate from structopt to clap 3.0 beta
This commit is contained in:
parent
51d239d5df
commit
d398077ed8
4 changed files with 81 additions and 61 deletions
108
Cargo.lock
generated
108
Cargo.lock
generated
|
@ -1,14 +1,5 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "ansi_term"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.38"
|
||||
|
@ -145,19 +136,36 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
|||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "2.33.3"
|
||||
version = "3.0.0-beta.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002"
|
||||
checksum = "4bd1061998a501ee7d4b6d449020df3266ca3124b941ec56cf2005c3779ca142"
|
||||
dependencies = [
|
||||
"ansi_term",
|
||||
"atty",
|
||||
"bitflags",
|
||||
"clap_derive",
|
||||
"indexmap",
|
||||
"lazy_static",
|
||||
"os_str_bytes",
|
||||
"strsim",
|
||||
"termcolor",
|
||||
"textwrap",
|
||||
"unicode-width",
|
||||
"vec_map",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "3.0.0-beta.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "370f715b81112975b1b69db93e0b56ea4cd4e5002ac43b2da8474106a54096a1"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro-error",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "concurrent-queue"
|
||||
version = "1.2.2"
|
||||
|
@ -323,6 +331,12 @@ dependencies = [
|
|||
"wasi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04"
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.3.2"
|
||||
|
@ -341,6 +355,16 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "1.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4fb1fa934250de4de8aef298d81c729a7d33d8c239daa3a7575e6b92bfc7313b"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "instant"
|
||||
version = "0.1.9"
|
||||
|
@ -416,6 +440,7 @@ dependencies = [
|
|||
"anyhow",
|
||||
"async-io",
|
||||
"async-net",
|
||||
"clap",
|
||||
"crossbeam-queue",
|
||||
"crossterm 0.19.0",
|
||||
"dirs-next",
|
||||
|
@ -423,7 +448,6 @@ dependencies = [
|
|||
"futures-lite",
|
||||
"ron",
|
||||
"serde",
|
||||
"structopt",
|
||||
"tui",
|
||||
]
|
||||
|
||||
|
@ -452,6 +476,12 @@ version = "1.5.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0"
|
||||
|
||||
[[package]]
|
||||
name = "os_str_bytes"
|
||||
version = "2.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "afb2e1c3ee07430c2cf76151675e583e0f19985fa6efae47d6848a3e2c824f85"
|
||||
|
||||
[[package]]
|
||||
name = "parking"
|
||||
version = "2.0.0"
|
||||
|
@ -645,33 +675,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.8.0"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
|
||||
|
||||
[[package]]
|
||||
name = "structopt"
|
||||
version = "0.3.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5277acd7ee46e63e5168a80734c9f6ee81b1367a7d8772a2d765df2a3705d28c"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"lazy_static",
|
||||
"structopt-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "structopt-derive"
|
||||
version = "0.4.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ba9cdfda491b814720b6b06e0cac513d922fc407582032e8706e9f137976f90"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro-error",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
|
@ -685,10 +691,19 @@ dependencies = [
|
|||
]
|
||||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.11.0"
|
||||
name = "termcolor"
|
||||
version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
|
||||
checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "203008d98caf094106cfaba70acfed15e18ed3ddb7d94e49baec153a2b462789"
|
||||
dependencies = [
|
||||
"unicode-width",
|
||||
]
|
||||
|
@ -780,6 +795,15 @@ version = "0.4.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
|
|
|
@ -17,6 +17,7 @@ categories = ["command-line-utilities"]
|
|||
anyhow = "1.0.38"
|
||||
async-io = "1.3.1"
|
||||
async-net = "1.5.0"
|
||||
clap = "3.0.0-beta.2"
|
||||
crossbeam-queue = "0.3.1"
|
||||
crossterm = "0.19.0"
|
||||
dirs-next = "2.0.0"
|
||||
|
@ -24,7 +25,6 @@ expand = "0.2.0"
|
|||
futures-lite = "1.11.3"
|
||||
ron = "0.6.4"
|
||||
serde = { version = "1.0.123", features = ["derive"] }
|
||||
structopt = "0.3.21"
|
||||
|
||||
[dependencies.tui]
|
||||
version = "0.14.0"
|
||||
|
|
28
src/app.rs
28
src/app.rs
|
@ -1,4 +1,4 @@
|
|||
use structopt::{clap::AppSettings, StructOpt};
|
||||
use clap::{AppSettings, Clap};
|
||||
use tui::widgets::ListState;
|
||||
|
||||
use std::{net::SocketAddr, path::PathBuf};
|
||||
|
@ -8,47 +8,43 @@ use crate::mpd::{Status, Track};
|
|||
/// Minimal mpd terminal client that aims to be simple yet highly configurable
|
||||
///
|
||||
/// Homepage: https://github.com/figsoda/mmtc
|
||||
#[derive(StructOpt)]
|
||||
#[structopt(
|
||||
name = "mmtc",
|
||||
rename_all = "kebab-case",
|
||||
global_setting = AppSettings::ColoredHelp,
|
||||
)]
|
||||
#[derive(Clap)]
|
||||
#[clap(global_setting = AppSettings::ColoredHelp)]
|
||||
pub struct Opts {
|
||||
/// Clear query on play
|
||||
#[structopt(long)]
|
||||
#[clap(long)]
|
||||
pub clear_query_on_play: bool,
|
||||
|
||||
/// Cycle through the queue
|
||||
#[structopt(long)]
|
||||
#[clap(long)]
|
||||
pub cycle: bool,
|
||||
|
||||
/// Don't clear query on play
|
||||
#[structopt(long, overrides_with("clear_query_on_play"))]
|
||||
#[clap(long, overrides_with("clear-query-on-play"))]
|
||||
pub no_clear_query_on_play: bool,
|
||||
|
||||
/// Don't cycle through the queue
|
||||
#[structopt(long, overrides_with("cycle"))]
|
||||
#[clap(long, overrides_with("cycle"))]
|
||||
pub no_cycle: bool,
|
||||
|
||||
/// Specify the address of the mpd server
|
||||
#[structopt(long, value_name = "address")]
|
||||
#[clap(long, value_name = "address")]
|
||||
pub address: Option<SocketAddr>,
|
||||
|
||||
/// Specify the config file
|
||||
#[structopt(short, long, value_name = "file")]
|
||||
#[clap(short, long, value_name = "file")]
|
||||
pub config: Option<PathBuf>,
|
||||
|
||||
/// The number of lines to jump
|
||||
#[structopt(long, value_name = "number")]
|
||||
#[clap(long, value_name = "number")]
|
||||
pub jump_lines: Option<usize>,
|
||||
|
||||
/// The time to seek in seconds
|
||||
#[structopt(long, value_name = "number")]
|
||||
#[clap(long, value_name = "number")]
|
||||
pub seek_secs: Option<f32>,
|
||||
|
||||
/// The amount of status updates per second
|
||||
#[structopt(long, value_name = "number")]
|
||||
#[clap(long, value_name = "number")]
|
||||
pub ups: Option<f32>,
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ mod mpd;
|
|||
|
||||
use anyhow::{Context, Result};
|
||||
use async_io::{block_on, Timer};
|
||||
use clap::Clap;
|
||||
use crossbeam_queue::SegQueue;
|
||||
use crossterm::{
|
||||
event::{
|
||||
|
@ -22,7 +23,6 @@ use crossterm::{
|
|||
};
|
||||
use dirs_next::config_dir;
|
||||
use futures_lite::StreamExt;
|
||||
use structopt::StructOpt;
|
||||
use tui::{backend::CrosstermBackend, widgets::ListState, Terminal};
|
||||
|
||||
use std::{
|
||||
|
@ -65,7 +65,7 @@ fn main() {
|
|||
}
|
||||
|
||||
async fn run() -> Result<()> {
|
||||
let opts = Opts::from_args();
|
||||
let opts = Opts::parse();
|
||||
|
||||
let cfg = if let Some(file) = opts.config {
|
||||
ron::de::from_bytes(&fs::read(&file).with_context(fail::read(file.display()))?)
|
||||
|
|
Loading…
Add table
Reference in a new issue