cli_table_derive/
lib.rs

1#![forbid(unsafe_code)]
2#![cfg_attr(not(any(docsrs, feature = "doc")), forbid(unstable_features))]
3#![deny(missing_docs)]
4#![cfg_attr(any(docsrs, feature = "doc"), feature(doc_cfg))]
5//! Derive macros for `cli-table` crate.
6//!
7//! For more details, see [`cli-table`](https://docs.rs/cli-table).
8mod context;
9mod table;
10mod utils;
11
12use proc_macro::TokenStream;
13use syn::{DeriveInput, parse_macro_input};
14
15#[proc_macro_derive(Table, attributes(table))]
16/// Derive macro to implementing `cli_table` traits
17pub fn table(input: TokenStream) -> TokenStream {
18    // Parse the input tokens into a syntax tree
19    let input = parse_macro_input!(input as DeriveInput);
20
21    // Prepare and return the output
22    table::table(input)
23        .unwrap_or_else(|err| err.to_compile_error())
24        .into()
25}