serum_dev_tools/
lib.rs

1use crate::config::ConfigOverride;
2use anchor_client::Cluster;
3use anyhow::Result;
4use clap::Parser;
5
6mod commands;
7pub mod config;
8mod errors;
9mod path;
10mod utils;
11
12pub const VERSION: &str = env!("CARGO_PKG_VERSION");
13
14#[derive(Parser, Debug)]
15#[clap(version = VERSION)]
16pub struct Opts {
17    #[clap(flatten)]
18    pub cfg_override: ConfigOverride,
19
20    #[clap(subcommand)]
21    command: Command,
22}
23
24#[derive(Debug, Parser)]
25pub enum Command {
26    /// Initializes a dev-tools workspace
27    Init,
28    /// Prints the address of the dex program
29    Instance,
30    /// Deploys the dex program to the specified cluster
31    Deploy {
32        /// The cluster to deploy to
33        cluster: Cluster,
34
35        /// The command to run after deploying
36        #[clap(long)]
37        command: Option<String>,
38    },
39}
40
41pub fn entry(opts: Opts) -> Result<()> {
42    match opts.command {
43        Command::Init => commands::init(),
44        Command::Instance => commands::instance(),
45        Command::Deploy { cluster, command } => {
46            commands::deploy(&opts.cfg_override, cluster, command)
47        }
48    }
49}