Skip to content

Commit

Permalink
optionally take args as input
Browse files Browse the repository at this point in the history
  • Loading branch information
nrdxp committed Jul 30, 2021
1 parent 3b6e84d commit 8a27483
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/bin/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 6 additions & 3 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 8a27483

Please sign in to comment.