clmm-common 0.1.39

Blockchain, Clmm for Solana
Documentation
use clap::{App, Arg};
use lazy_static::lazy_static;

lazy_static! {
    pub static ref CONFIG_FILE: Option<String> = {
        dirs_next::home_dir().map(|mut path| {
            path.extend(&[".config", "solana", "cli", "config.yml"]);
            path.to_str().unwrap().to_string()
        })
    };
}

pub fn get_clap_app<'ab, 'v>(name: &str, about: &'ab str, version: &'ab str) -> App<'ab, 'v> {
    App::new(name)
        .about(about)
        .version(version)
        .arg(
            {
                let arg = Arg::with_name("config_file")
                    .short("C")
                    .long("config")
                    .value_name("CONFIG_FILE")
                    .global(true)
                    .takes_value(true)
                    .help("crema cli config, consistent with the solana cli config (default: $HOME/.config/solana/cli/config.yml)");
                if let Some(ref config_file) = *CONFIG_FILE {
                    arg.default_value(config_file)
                } else {
                    arg
                }
            }
        )
        .arg(
            Arg::with_name("owner")
                .short("o")
                .long("owner")
                .value_name("OWNER")
                .global(true)
                .takes_value(true)
                .help("owner key")
        )
}