1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use std::path::PathBuf;
use structopt::{clap, StructOpt};

pub trait CommandCli: StructOpt {
    fn workdir(&self) -> Option<PathBuf>;
    fn command(&self) -> &Command;
}

#[derive(Clone, Debug, Eq, PartialEq, StructOpt)]
#[structopt(setting = clap::AppSettings::DeriveDisplayOrder)]
pub enum Command {
    /// Deploy the runtime
    Deploy { args: Vec<String> },
    /// Start the runtime
    Start { args: Vec<String> },
    /// Run a runtime command
    Run { args: Vec<String> },
    /// Output a market offer template JSON
    OfferTemplate { args: Vec<String> },
    /// Perform a self-test
    Test { args: Vec<String> },
}

impl Command {
    pub fn args(&self) -> &Vec<String> {
        match self {
            Self::Deploy { args }
            | Self::Start { args }
            | Self::Run { args }
            | Self::OfferTemplate { args }
            | Self::Test { args } => &args,
        }
    }
}

#[derive(StructOpt)]
pub struct EmptyArgs {}