crema-cli 0.1.0

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

pub trait PositionSubCommand {
    fn position_subcommands(self) -> Self;
}

impl PositionSubCommand for App<'_, '_> {
    fn position_subcommands(self) -> Self {
        self.subcommand(
            SubCommand::with_name("pos")
                .about("position")
                .alias("position")
                .subcommands(
                    vec![
                        SubCommand::with_name("decr").about("decrease liquidity to position")
                            .args(
                                &[
                                    Arg::with_name("mint")
                                        .index(1)
                                        .value_name("MINT")
                                        .required(true)
                                        .help("provider the position mint address"),
                                    Arg::with_name("amount_a")
                                        .short("a")
                                        .long("amount_a").value_name("AMOUNT_A").global(true).takes_value(true).default_value("0")
                                        .help("The token amount a"),
                                    Arg::with_name("amount_b")
                                        .short("b")
                                        .long("amount_b").value_name("AMOUNT_B").global(true).takes_value(true).default_value("0")
                                        .help("The token amount b"),
                                    Arg::with_name("slid")
                                        .short("s")
                                        .long("slid").hidden(true).value_name("SLID").global(true).takes_value(true).default_value("0.01")
                                        .help("The slid rate (default 0.01)"),
                                ]
                            ),
                        SubCommand::with_name("incr").about("increase liquidity to position")
                            .args(
                                &[
                                    Arg::with_name("mint")
                                        .index(1)
                                        .value_name("MINT")
                                        .required(true)
                                        .help("provider the position mint address"),
                                    Arg::with_name("amount_a")
                                        .short("a")
                                        .long("amount_a").value_name("AMOUNT_A").global(true).takes_value(true).default_value("0")
                                        .help("The token amount a"),
                                    Arg::with_name("amount_b")
                                        .short("b")
                                        .long("amount_b").value_name("AMOUNT_B").global(true).takes_value(true).default_value("0")
                                        .help("The token amount b"),
                                    Arg::with_name("slid")
                                        .short("s")
                                        .long("slid").hidden(true).value_name("SLID").global(true).takes_value(true).default_value("0.01")
                                        .help("The slid rate (default 0.01)"),
                                ]
                            ),
                        SubCommand::with_name("open").about("open a new position")
                            .args(
                                &[
                                    Arg::with_name("clmmpool")
                                        .index(1).value_name("CLMMPOOL").required(true)
                                        .help("The clmmpool"),
                                    Arg::with_name("tick_lower_index")
                                        .short("l")
                                        .set(ArgSettings::AllowLeadingHyphen)
                                        .value_name("TICK_LOWER_INDEX").required(true)
                                        .help("The tick lower index"),
                                    Arg::with_name("tick_upper_index")
                                        .short("u")
                                        .set(ArgSettings::AllowLeadingHyphen)
                                        .value_name("TICK_UPPER_INDEX").required(true)
                                        .help("The tick upper index"),
                                ]
                            ),
                        SubCommand::with_name("remove").about("remove a position")
                            .args(
                                &[
                                    Arg::with_name("mint")
                                        .index(1)
                                        .value_name("MINT")
                                        .required(true)
                                        .help("provider the position mint address"),
                                ]
                            ),
                        SubCommand::with_name("info").about("get position info")
                            .arg(
                                Arg::with_name("mint")
                                    .index(1)
                                    .value_name("MINT")
                                    .required(true)
                                    .help("provider the position mint address to retreive the position details"),
                            ),
                        SubCommand::with_name("collect_fee")
                            .about("position owner to collect the fee the position owned")
                            .args(
                                &[
                                    Arg::with_name("mint")
                                        .index(1)
                                        .value_name("MINT")
                                        .required(true)
                                        .help("provider the position mint address"),
                                ]
                            ),
                    ]
                )
        )
    }
}