Skip to main content

clap_derive_v3/
lib.rs

1// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>,
2// Kevin Knapp (@kbknapp) <kbknapp@gmail.com>, and
3// Andrew Hobden (@hoverbear) <andrew@hoverbear.org>
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10//
11// This work was derived from Structopt (https://github.com/TeXitoi/structopt)
12// commit#ea76fa1b1b273e65e3b0b1046643715b49bec51f which is licensed under the
13// MIT/Apache 2.0 license.
14
15//! This crate is custom derive for clap. It should not be used
16//! directly. See [clap documentation](https://docs.rs/clap)
17//! for the usage of `#[derive(Clap)]`.
18
19extern crate proc_macro;
20
21use proc_macro_error::proc_macro_error;
22
23mod derives;
24
25// /// It is required to have this seperate and specificly defined.
26// #[proc_macro_derive(ArgEnum, attributes(case_sensitive))]
27// pub fn arg_enum(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
28//     let input: syn::DeriveInput = syn::parse(input).unwrap();
29//     derives::derive_arg_enum(&input).into()
30// }
31
32/// Generates the `Clap` impl.
33#[proc_macro_derive(Clap, attributes(clap))]
34#[proc_macro_error]
35pub fn clap(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
36    let input: syn::DeriveInput = syn::parse_macro_input!(input);
37    derives::derive_clap(&input).into()
38}