crema-cli 0.1.0

Blockchain, Crema for Solana
Documentation
use clap::{App, Arg, ArgSettings, SubCommand};

pub trait TickSubCommand {
    fn tick_subcommands(self) -> Self;
}

impl TickSubCommand for App<'_, '_> {
    fn tick_subcommands(self) -> Self {
        self.subcommand(
            SubCommand::with_name("ticks")
                .about("tick info")
                .alias("ticks")
                .subcommands(vec![
                    SubCommand::with_name("tick")
                        .about("decrease liquidity to position")
                        .args(&[
                            Arg::with_name("pool")
                                .index(1)
                                .value_name("POOL")
                                .required(true)
                                .help("The pool to see tick info"),
                            Arg::with_name("tick_index")
                                .index(2)
                                .set(ArgSettings::AllowLeadingHyphen)
                                .value_name("TICK_INDEX")
                                .required(true)
                                .help("The tick index"),
                        ]),
                    SubCommand::with_name("array")
                        .about("tick array info")
                        .args(&[
                            Arg::with_name("pool")
                                .index(1)
                                .value_name("POOL")
                                .required(true)
                                .help("The pool to see tick info"),
                            Arg::with_name("tick_index")
                                .short("t")
                                .set(ArgSettings::AllowLeadingHyphen)
                                .long("tick_index")
                                .value_name("TICK_INDEX")
                                .global(true)
                                .takes_value(true)
                                .help("the tick array contains this tick index"),
                            Arg::with_name("array_index")
                                .short("a")
                                .set(ArgSettings::AllowLeadingHyphen)
                                .long("array_index")
                                .value_name("ARRAY_INDEX")
                                .global(true)
                                .takes_value(true)
                                .help("The array index"),
                        ]),
                    SubCommand::with_name("map")
                        .about("tick array map info")
                        .args(&[
                            Arg::with_name("pool")
                                .index(1)
                                .value_name("POOL")
                                .required(true)
                                .help("The clmmpool"),
                            Arg::with_name("array_index")
                                .index(2)
                                .set(ArgSettings::AllowLeadingHyphen)
                                .value_name("ARRAY_INDEX")
                                .required(true)
                                .help("The array index"),
                        ]),
                    SubCommand::with_name("price")
                        .about("tick to price")
                        .args(&[Arg::with_name("tick")
                            .short("t")
                            .set(ArgSettings::AllowLeadingHyphen)
                            .value_name("tick")
                            .required(true)
                            .help("The tick index")]),
                ]),
        )
    }
}