Skip to content

Commit 8a27483

Browse files
committed
optionally take args as input
1 parent 3b6e84d commit 8a27483

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/bin/deploy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use log::error;
88

99
#[tokio::main]
1010
async fn main() -> Result<(), Box<dyn std::error::Error>> {
11-
match cli::run().await {
11+
match cli::run(None).await {
1212
Ok(()) => (),
1313
Err(err) => {
1414
error!("{}", err);

src/cli.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use std::collections::HashMap;
77
use std::io::{stdin, stdout, Write};
88

9-
use clap::Clap;
9+
use clap::{Clap, ArgMatches, FromArgMatches};
1010

1111
use crate as deploy;
1212

@@ -607,8 +607,11 @@ pub enum RunError {
607607
RunDeploy(#[from] RunDeployError),
608608
}
609609

610-
pub async fn run() -> Result<(), RunError> {
611-
let opts: Opts = Opts::parse();
610+
pub async fn run(args: Option<&ArgMatches>) -> Result<(), RunError> {
611+
let opts = match args {
612+
Some(o) => <Opts as FromArgMatches>::from_arg_matches(o),
613+
None => Opts::parse(),
614+
};
612615

613616
deploy::init_logger(
614617
opts.debug_logs,

0 commit comments

Comments
 (0)