1 //! Dummy implementations that we emit along with an error. 2 3 use proc_macro2::Ident; 4 use proc_macro_error::append_dummy; 5 use quote::quote; 6 parser_struct(name: &Ident)7pub fn parser_struct(name: &Ident) { 8 into_app(name); 9 args(name); 10 append_dummy(quote!( impl clap::Parser for #name {} )); 11 } 12 parser_enum(name: &Ident)13pub fn parser_enum(name: &Ident) { 14 into_app(name); 15 subcommand(name); 16 append_dummy(quote!( impl clap::Parser for #name {} )); 17 } 18 into_app(name: &Ident)19pub fn into_app(name: &Ident) { 20 append_dummy(quote! { 21 impl clap::CommandFactory for #name { 22 fn command<'b>() -> clap::Command { 23 unimplemented!() 24 } 25 fn command_for_update<'b>() -> clap::Command { 26 unimplemented!() 27 } 28 } 29 }); 30 } 31 from_arg_matches(name: &Ident)32pub fn from_arg_matches(name: &Ident) { 33 append_dummy(quote! { 34 impl clap::FromArgMatches for #name { 35 fn from_arg_matches(_m: &clap::ArgMatches) -> ::std::result::Result<Self, clap::Error> { 36 unimplemented!() 37 } 38 fn update_from_arg_matches(&mut self, matches: &clap::ArgMatches) -> ::std::result::Result<(), clap::Error>{ 39 unimplemented!() 40 } 41 } 42 }); 43 } 44 subcommand(name: &Ident)45pub fn subcommand(name: &Ident) { 46 from_arg_matches(name); 47 append_dummy(quote! { 48 impl clap::Subcommand for #name { 49 fn augment_subcommands(_cmd: clap::Command) -> clap::Command { 50 unimplemented!() 51 } 52 fn augment_subcommands_for_update(_cmd: clap::Command) -> clap::Command { 53 unimplemented!() 54 } 55 fn has_subcommand(name: &str) -> bool { 56 unimplemented!() 57 } 58 } 59 }); 60 } 61 args(name: &Ident)62pub fn args(name: &Ident) { 63 from_arg_matches(name); 64 append_dummy(quote! { 65 impl clap::Args for #name { 66 fn augment_args(_cmd: clap::Command) -> clap::Command { 67 unimplemented!() 68 } 69 fn augment_args_for_update(_cmd: clap::Command) -> clap::Command { 70 unimplemented!() 71 } 72 } 73 }); 74 } 75 value_enum(name: &Ident)76pub fn value_enum(name: &Ident) { 77 append_dummy(quote! { 78 impl clap::ValueEnum for #name { 79 fn value_variants<'a>() -> &'a [Self]{ 80 unimplemented!() 81 } 82 fn from_str(_input: &str, _ignore_case: bool) -> ::std::result::Result<Self, String> { 83 unimplemented!() 84 } 85 fn to_possible_value<'a>(&self) -> ::std::option::Option<clap::builder::PossibleValue>{ 86 unimplemented!() 87 } 88 } 89 }) 90 } 91