diff --git a/src/main.rs b/src/main.rs index 23826c39f..3eba3b566 100644 --- a/src/main.rs +++ b/src/main.rs @@ -25,7 +25,7 @@ use hayabusa::detections::utils; use hayabusa::detections::utils::{ check_setting_path, get_writable_color, output_and_data_stack_for_html, output_profile_name, }; -use hayabusa::options::auto_complete::{print_completer, select_shell}; +use hayabusa::options::auto_complete::auto_complete; use hayabusa::options::htmlreport::{self, HTML_REPORTER}; use hayabusa::options::pivot::create_output; use hayabusa::options::pivot::PIVOT_KEYWORD; @@ -147,8 +147,7 @@ impl App { //ロゴと時間が表示さないように実行したい if let Action::AutoComplete(_) = &stored_static.config.action.as_ref().unwrap() { - let shell = select_shell(); - print_completer(shell, app); + auto_complete(app); return; } diff --git a/src/options/auto_complete.rs b/src/options/auto_complete.rs index a8dfd5016..c5da47b2a 100644 --- a/src/options/auto_complete.rs +++ b/src/options/auto_complete.rs @@ -1,7 +1,12 @@ use clap_complete::{generate, Generator, Shell}; use dialoguer::Select; -pub fn select_shell() -> Shell { +pub fn auto_complete(app: &mut clap::Command) { + let shell = select_shell(); + print_completer(shell, app); +} + +fn select_shell() -> Shell { let items:Vec = vec![Shell::Bash, Shell::Elvish, Shell::Fish, Shell::PowerShell, Shell::Zsh]; let selection = Select::new() @@ -12,7 +17,7 @@ pub fn select_shell() -> Shell { items[selection] } -pub fn print_completer(generator: G, app: &mut clap::Command) { +fn print_completer(generator: G, app: &mut clap::Command) { let name = app.get_name().to_owned(); generate(generator, app, name, &mut std::io::stdout());