diff options
author | Timothy DeHerrera | 2021-07-15 10:44:40 -0600 |
---|---|---|
committer | Timothy DeHerrera | 2021-07-29 18:17:53 -0600 |
commit | 8a27483dce6490eae77b5064a632a91b68c2d10c (patch) | |
tree | c49e5fbcdb7f207451b0bfefa903e9b8997a88f2 | |
parent | 3b6e84d3e274606432876b97b586d06771a3216f (diff) |
optionally take args as input
-rw-r--r-- | src/bin/deploy.rs | 2 | ||||
-rw-r--r-- | src/cli.rs | 9 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/bin/deploy.rs b/src/bin/deploy.rs index 6686258..e924dc9 100644 --- a/src/bin/deploy.rs +++ b/src/bin/deploy.rs @@ -8,7 +8,7 @@ use log::error; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { - match cli::run().await { + match cli::run(None).await { Ok(()) => (), Err(err) => { error!("{}", err); @@ -6,7 +6,7 @@ use std::collections::HashMap; use std::io::{stdin, stdout, Write}; -use clap::Clap; +use clap::{Clap, ArgMatches, FromArgMatches}; use crate as deploy; @@ -607,8 +607,11 @@ pub enum RunError { RunDeploy(#[from] RunDeployError), } -pub async fn run() -> Result<(), RunError> { - let opts: Opts = Opts::parse(); +pub async fn run(args: Option<&ArgMatches>) -> Result<(), RunError> { + let opts = match args { + Some(o) => <Opts as FromArgMatches>::from_arg_matches(o), + None => Opts::parse(), + }; deploy::init_logger( opts.debug_logs, |