From 3047c83714b28432fb8b4b60261f761526eb1f2e Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Tue, 18 Apr 2023 17:26:50 +0200 Subject: add shell completion --- src/main.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') 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