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