diff --git a/clap_generate_fig/examples/fig_completion.rs b/clap_generate_fig/examples/fig_completion.rs index aac6d275..7d3ad69c 100644 --- a/clap_generate_fig/examples/fig_completion.rs +++ b/clap_generate_fig/examples/fig_completion.rs @@ -8,5 +8,5 @@ fn main() { .subcommand(App::new("test").subcommand(App::new("config"))) .subcommand(App::new("hello")); - generate::(&mut app, "myapp", &mut io::stdout()); + generate(Fig, &mut app, "myapp", &mut io::stdout()); } diff --git a/clap_generate_fig/src/fig.rs b/clap_generate_fig/src/fig.rs index d10db221..80c737a5 100644 --- a/clap_generate_fig/src/fig.rs +++ b/clap_generate_fig/src/fig.rs @@ -9,11 +9,11 @@ use clap_generate::*; pub struct Fig; impl Generator for Fig { - fn file_name(name: &str) -> String { + fn file_name(&self, name: &str) -> String { format!("{}.ts", name) } - fn generate(app: &App, buf: &mut dyn Write) { + fn generate(&self, app: &App, buf: &mut dyn Write) { let command = app.get_bin_name().unwrap(); let mut buffer = String::new(); @@ -160,7 +160,7 @@ fn gen_options(app: &App, indent: usize) -> String { buffer.push_str(&format!("{:indent$}}},\n", "", indent = indent + 2)); } - for flag in Fig::flags(app) { + for flag in utils::flags(app) { buffer.push_str(&format!("{:indent$}{{\n", "", indent = indent + 2)); let mut flags = vec![]; diff --git a/clap_generate_fig/tests/completions/fig.rs b/clap_generate_fig/tests/completions/fig.rs index c21388d8..324a7d09 100644 --- a/clap_generate_fig/tests/completions/fig.rs +++ b/clap_generate_fig/tests/completions/fig.rs @@ -26,7 +26,7 @@ fn build_app_with_name(s: &'static str) -> App<'static> { #[test] fn fig() { let mut app = build_app(); - common::(&mut app, "myapp", FIG); + common(Fig, &mut app, "myapp", FIG); } static FIG: &str = r#"const completion: Fig.Spec = { @@ -93,7 +93,7 @@ export default completion; #[test] fn fig_with_special_commands() { let mut app = build_app_special_commands(); - common::(&mut app, "my_app", FIG_SPECIAL_CMDS); + common(Fig, &mut app, "my_app", FIG_SPECIAL_CMDS); } fn build_app_special_commands() -> App<'static> { @@ -208,7 +208,7 @@ export default completion; #[test] fn fig_with_special_help() { let mut app = build_app_special_help(); - common::(&mut app, "my_app", FIG_SPECIAL_HELP); + common(Fig, &mut app, "my_app", FIG_SPECIAL_HELP); } fn build_app_special_help() -> App<'static> { @@ -286,7 +286,7 @@ export default completion; #[test] fn fig_with_aliases() { let mut app = build_app_with_aliases(); - common::(&mut app, "cmd", FIG_ALIASES); + common(Fig, &mut app, "cmd", FIG_ALIASES); } fn build_app_with_aliases() -> App<'static> { @@ -349,7 +349,7 @@ export default completion; #[test] fn fig_with_sub_subcommands() { let mut app = build_app_sub_subcommands(); - common::(&mut app, "my_app", FIG_SUB_SUBCMDS); + common(Fig, &mut app, "my_app", FIG_SUB_SUBCMDS); } fn build_app_sub_subcommands() -> App<'static> { diff --git a/clap_generate_fig/tests/completions/mod.rs b/clap_generate_fig/tests/completions/mod.rs index b149f51f..4cfa60af 100644 --- a/clap_generate_fig/tests/completions/mod.rs +++ b/clap_generate_fig/tests/completions/mod.rs @@ -19,9 +19,9 @@ macro_rules! assert_eq { }; } -pub fn common(app: &mut App, name: &str, fixture: &str) { +pub fn common(gen: G, app: &mut App, name: &str, fixture: &str) { let mut buf = vec![]; - generate::(app, name, &mut buf); + generate(gen, app, name, &mut buf); let string = String::from_utf8(buf).unwrap(); assert_eq!(&string, fixture); diff --git a/clap_generate_fig/tests/generate_completions.rs b/clap_generate_fig/tests/generate_completions.rs index b1203f39..21021717 100644 --- a/clap_generate_fig/tests/generate_completions.rs +++ b/clap_generate_fig/tests/generate_completions.rs @@ -19,5 +19,5 @@ fn generate_completions() { .arg(Arg::new("debug").short('d')), ); - generate::(&mut app, "test_app", &mut io::sink()); + generate(Fig, &mut app, "test_app", &mut io::sink()); } diff --git a/clap_generate_fig/tests/value_hints.rs b/clap_generate_fig/tests/value_hints.rs index eaea7cf9..08946677 100644 --- a/clap_generate_fig/tests/value_hints.rs +++ b/clap_generate_fig/tests/value_hints.rs @@ -211,5 +211,5 @@ export default completion; #[test] fn fig_with_value_hints() { let mut app = build_app_with_value_hints(); - common::(&mut app, "my_app", FIG_VALUE_HINTS); + common(Fig, &mut app, "my_app", FIG_VALUE_HINTS); }