inkpad_cli/
lib.rs

1//! Inkpad CLI Library
2use structopt::StructOpt;
3
4mod cmd;
5mod result;
6mod store;
7mod tx;
8pub mod util;
9
10use self::cmd::{Command, Opt};
11pub use self::{
12    result::{Error, Result},
13    store::Storage,
14    tx::Tx,
15};
16
17/// Run CLI
18pub fn run() -> Result<()> {
19    let opt = Opt::from_args();
20    let mut store = Storage::new()?;
21    let mut rt = store.rt(&opt.contract.unwrap_or_else(|| "".to_string()))?;
22
23    match opt.command {
24        Command::List => cmd::list::exec(&store)?,
25        Command::Info => cmd::info::exec(&rt)?,
26        Command::Deploy(tx) => cmd::deploy::exec(&mut rt, tx)?,
27        Command::Call(tx) => cmd::call::exec(&mut rt, tx)?,
28    }
29
30    Ok(())
31}