aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimothy DeHerrera2021-07-15 10:44:40 -0600
committerTimothy DeHerrera2021-07-29 18:17:53 -0600
commit8a27483dce6490eae77b5064a632a91b68c2d10c (patch)
treec49e5fbcdb7f207451b0bfefa903e9b8997a88f2 /src
parent3b6e84d3e274606432876b97b586d06771a3216f (diff)
optionally take args as input
Diffstat (limited to 'src')
-rw-r--r--src/bin/deploy.rs2
-rw-r--r--src/cli.rs9
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);
diff --git a/src/cli.rs b/src/cli.rs
index 2fdaaec..9214ebd 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -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,