Upgrade to Clap v4

This commit is contained in:
Henrik Friedrichsen
2022-10-02 22:11:10 +02:00
parent 9464c3da77
commit c2ab691722
3 changed files with 13 additions and 22 deletions

16
Cargo.lock generated
View File

@@ -309,24 +309,22 @@ dependencies = [
[[package]]
name = "clap"
version = "3.2.22"
version = "4.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86447ad904c7fb335a790c9d7fe3d0d971dc523b8ccd1561a520de9a85302750"
checksum = "5840cd9093aabeabf7fd932754c435b7674520fc3ddc935c397837050f0f1e4b"
dependencies = [
"atty",
"bitflags",
"clap_lex",
"indexmap",
"strsim",
"termcolor",
"textwrap",
]
[[package]]
name = "clap_lex"
version = "0.2.4"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5"
checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8"
dependencies = [
"os_str_bytes",
]
@@ -2954,12 +2952,6 @@ dependencies = [
"redox_termios",
]
[[package]]
name = "textwrap"
version = "0.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "949517c0cf1bf4ee812e2e07e08ab448e3ae0d23472aee8a06c985f0c8815b16"
[[package]]
name = "thiserror"
version = "1.0.37"

View File

@@ -15,7 +15,7 @@ maintenance = {status = "actively-developed"}
[dependencies]
chrono = "0.4"
clap = "3.2.17"
clap = "4.0.0"
clipboard = {version = "0.5", optional = true}
crossbeam-channel = "0.5"
dbus = {version = "0.9.6", optional = true}

View File

@@ -103,22 +103,20 @@ async fn main() -> Result<(), String> {
.version(env!("CARGO_PKG_VERSION"))
.author("Henrik Friedrichsen <henrik@affekt.org> and contributors")
.about("cross-platform ncurses Spotify client")
.after_help(&*backends)
.after_help(backends)
.arg(
Arg::new("debug")
.short('d')
.long("debug")
.value_name("FILE")
.help("Enable debug logging to the specified file")
.takes_value(true),
.help("Enable debug logging to the specified file"),
)
.arg(
Arg::new("basepath")
.short('b')
.long("basepath")
.value_name("PATH")
.help("custom basepath to config/cache files")
.takes_value(true),
.help("custom basepath to config/cache files"),
)
.arg(
Arg::new("config")
@@ -126,16 +124,15 @@ async fn main() -> Result<(), String> {
.long("config")
.value_name("FILE")
.help("Filename of config file in basepath")
.takes_value(true)
.default_value("config.toml"),
)
.get_matches();
if let Some(filename) = matches.value_of("debug") {
if let Some(filename) = matches.get_one::<String>("debug") {
setup_logging(filename).expect("can't setup logging");
}
if let Some(basepath) = matches.value_of("basepath") {
if let Some(basepath) = matches.get_one::<String>("basepath") {
let path = PathBuf::from_str(basepath).expect("invalid path");
if !path.exists() {
fs::create_dir_all(&path).expect("could not create basepath directory");
@@ -146,7 +143,9 @@ async fn main() -> Result<(), String> {
// Things here may cause the process to abort; we must do them before creating curses windows
// otherwise the error message will not be seen by a user
let cfg: Arc<crate::config::Config> = Arc::new(Config::new(
matches.value_of("config").unwrap_or("config.toml"),
matches
.get_one::<String>("config")
.unwrap_or(&"config.toml".to_string()),
));
let mut credentials = {
let cache = Cache::new(Some(config::cache_path("librespot")), None, None, None)