fix(fig): Get compiling

This commit is contained in:
Ed Page 2021-10-12 07:57:26 -05:00
parent 36e172672c
commit fa0deb03cf
6 changed files with 13 additions and 13 deletions

View file

@ -8,5 +8,5 @@ fn main() {
.subcommand(App::new("test").subcommand(App::new("config")))
.subcommand(App::new("hello"));
generate::<Fig, _>(&mut app, "myapp", &mut io::stdout());
generate(Fig, &mut app, "myapp", &mut io::stdout());
}

View file

@ -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![];

View file

@ -26,7 +26,7 @@ fn build_app_with_name(s: &'static str) -> App<'static> {
#[test]
fn fig() {
let mut app = build_app();
common::<Fig>(&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::<Fig>(&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::<Fig>(&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::<Fig>(&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::<Fig>(&mut app, "my_app", FIG_SUB_SUBCMDS);
common(Fig, &mut app, "my_app", FIG_SUB_SUBCMDS);
}
fn build_app_sub_subcommands() -> App<'static> {

View file

@ -19,9 +19,9 @@ macro_rules! assert_eq {
};
}
pub fn common<G: Generator>(app: &mut App, name: &str, fixture: &str) {
pub fn common<G: Generator>(gen: G, app: &mut App, name: &str, fixture: &str) {
let mut buf = vec![];
generate::<G, _>(app, name, &mut buf);
generate(gen, app, name, &mut buf);
let string = String::from_utf8(buf).unwrap();
assert_eq!(&string, fixture);

View file

@ -19,5 +19,5 @@ fn generate_completions() {
.arg(Arg::new("debug").short('d')),
);
generate::<Fig, _>(&mut app, "test_app", &mut io::sink());
generate(Fig, &mut app, "test_app", &mut io::sink());
}

View file

@ -211,5 +211,5 @@ export default completion;
#[test]
fn fig_with_value_hints() {
let mut app = build_app_with_value_hints();
common::<Fig>(&mut app, "my_app", FIG_VALUE_HINTS);
common(Fig, &mut app, "my_app", FIG_VALUE_HINTS);
}