From 77d2ac94534b12300b5b7eff6e28023d815708eb Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Tue, 4 Apr 2023 20:50:09 +0200 Subject: add clap & cargo update --- Cargo.toml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Cargo.toml') diff --git a/Cargo.toml b/Cargo.toml index 7d55c00..1f5c1cf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,9 +10,10 @@ reqwest = { version = "0.11", features = ["json", "stream"] } tokio = { version = "1", features = ["full"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0.87" -rusqlite = { version = "0.28.0", features = ["bundled"] } +rusqlite = { version = "0.29.0", features = ["bundled"] } futures-util = "0.3.14" chrono = "0.4.22" toml = "0.7.2" error-chain = "0.12.4" -dirs = "4.0.0" +dirs = "5.0.0" +clap = { version = "4.2.1", features = ["derive"] } -- cgit v1.2.3 From 3047c83714b28432fb8b4b60261f761526eb1f2e Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Tue, 18 Apr 2023 17:26:50 +0200 Subject: add shell completion --- Cargo.lock | 73 ++++++++++++++++++++++++++++++++++++++----------------------- Cargo.toml | 3 ++- src/main.rs | 10 +++++++-- 3 files changed, 56 insertions(+), 30 deletions(-) (limited to 'Cargo.toml') diff --git a/Cargo.lock b/Cargo.lock index 5638eb6..f99cd87 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -39,42 +39,51 @@ dependencies = [ [[package]] name = "anstream" -version = "0.2.6" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "342258dd14006105c2b75ab1bd7543a03bdf0cfc94383303ac212a04939dff6f" +checksum = "9e579a7752471abc2a8268df8b20005e3eadd975f585398f17efcfd8d4927371" dependencies = [ "anstyle", "anstyle-parse", + "anstyle-query", "anstyle-wincon", - "concolor-override", - "concolor-query", + "colorchoice", "is-terminal", "utf8parse", ] [[package]] name = "anstyle" -version = "0.3.5" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23ea9e81bd02e310c216d080f6223c179012256e5151c41db88d12c88a1684d2" +checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" [[package]] name = "anstyle-parse" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7d1bb534e9efed14f3e5f44e7dd1a4f709384023a4165199a4241e18dff0116" +checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" dependencies = [ "utf8parse", ] +[[package]] +name = "anstyle-query" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +dependencies = [ + "windows-sys 0.48.0", +] + [[package]] name = "anstyle-wincon" -version = "0.2.0" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3127af6145b149f3287bb9a0d10ad9c5692dba8c53ad48285e5bec4063834fa" +checksum = "4bcd8291a340dd8ac70e18878bc4501dd7b4ff970cfa21c207d36ece51ea88fd" dependencies = [ "anstyle", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -157,9 +166,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.2.1" +version = "4.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "046ae530c528f252094e4a77886ee1374437744b2bff1497aa898bbddbbb29b3" +checksum = "9b802d85aaf3a1cdb02b224ba472ebdea62014fccfcb269b95a4d76443b5ee5a" dependencies = [ "clap_builder", "clap_derive", @@ -168,9 +177,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.2.1" +version = "4.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "223163f58c9a40c3b0a43e1c4b50a9ce09f007ea2cb1ec258a687945b4b7929f" +checksum = "14a1a858f532119338887a4b8e1af9c60de8249cd7bafd68036a489e261e37b6" dependencies = [ "anstream", "anstyle", @@ -179,6 +188,15 @@ dependencies = [ "strsim", ] +[[package]] +name = "clap_complete" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01c22dcfb410883764b29953103d9ef7bb8fe21b3fa1158bc99986c2067294bd" +dependencies = [ + "clap", +] + [[package]] name = "clap_derive" version = "4.2.0" @@ -208,19 +226,10 @@ dependencies = [ ] [[package]] -name = "concolor-override" +name = "colorchoice" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a855d4a1978dc52fb0536a04d384c2c0c1aa273597f08b77c8c4d3b2eec6037f" - -[[package]] -name = "concolor-query" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d11d52c3d7ca2e6d0040212be9e4dbbcd78b6447f535b6b561f449427944cf" -dependencies = [ - "windows-sys 0.45.0", -] +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "core-foundation" @@ -789,10 +798,11 @@ dependencies = [ [[package]] name = "modlist" -version = "0.11.1" +version = "0.12.0" dependencies = [ "chrono", "clap", + "clap_complete", "dirs", "error-chain", "futures-util", @@ -1660,6 +1670,15 @@ dependencies = [ "windows-targets 0.42.2", ] +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.0", +] + [[package]] name = "windows-targets" version = "0.42.2" diff --git a/Cargo.toml b/Cargo.toml index 1f5c1cf..51652f3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "modlist" -version = "0.11.1" +version = "0.12.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -17,3 +17,4 @@ toml = "0.7.2" error-chain = "0.12.4" dirs = "5.0.0" clap = { version = "4.2.1", features = ["derive"] } +clap_complete = "4.2.0" diff --git a/src/main.rs b/src/main.rs index 0dfc190..a9071f1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,7 @@ -use clap::{Parser, Subcommand}; +use clap::{Parser, Subcommand, CommandFactory}; use modlist::{config::Cfg, mod_add, mod_remove, db::{lists_get, config_get_current_list, lists_get_all_ids}, IDSelector, download, update, List, get_current_list, import, devdir, export, list_add, Modloader, list_version, list_remove, list_change}; //TODO make default list optional - #[derive(Parser)] #[command(author, version, about)] struct Cli { @@ -61,6 +60,9 @@ enum Commands { Export { /// the list you want to export list: Option + }, + Completions { + shell: clap_complete::Shell, } } @@ -233,5 +235,9 @@ async fn main() { Commands::Export { list } => { export(config, list) }, + Commands::Completions { shell } => { + clap_complete::generate(shell, &mut Cli::command(), "modlist", &mut std::io::stdout()); + Ok(()) + } }.unwrap(); } -- cgit v1.2.3