Trait clap_generate::Generator[][src]

pub trait Generator {
    fn file_name(&self, name: &str) -> String;
fn generate(&self, app: &App<'_>, buf: &mut dyn Write); }
Expand description

Generator trait which can be used to write generators

Required methods

Returns the file name that is created when this generator is called during compile time.

Examples
use clap_generate::Generator;

pub struct Fish;

impl Generator for Fish {
    fn file_name(&self, name: &str) -> String {
        format!("{}.fish", name)
    }
}

Generates output out of clap::App.

Examples

The following example generator displays the clap::App as if it is printed using std::println.

use std::{io::Write, fmt::write};
use clap::App;
use clap_generate::Generator;

pub struct ClapDebug;

impl Generator for ClapDebug {
    fn generate(&self, app: &App, buf: &mut dyn Write) {
        write!(buf, "{}", app).unwrap();
    }
}

Implementors