Skip to content

Commit

Permalink
fix: update clap requirement from 2.33.3 to 3.0.0 (#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
gangliao authored Jan 1, 2022
1 parent 72991f8 commit ea8006b
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 80 deletions.
2 changes: 1 addition & 1 deletion flock-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ default = [ "cli" ]
[dependencies]
anyhow = "1.0.51"
benchmarks = { path = "../benchmarks" }
clap = "2.33.3"
clap = { version = "3.0.0", features = [ "cargo" ] }
ctrlc = "3.1.1"
env_logger = "^0.9"
futures = "0.3.12"
Expand Down
14 changes: 7 additions & 7 deletions flock-cli/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,30 @@ use benchmarks::rainbow_string;
use clap::{Arg, ArgMatches};
use std::io::Write;

pub fn get_args() -> Vec<Arg<'static, 'static>> {
let config = Arg::with_name("config")
.short("c")
pub fn get_args() -> Vec<Arg<'static>> {
let config = Arg::new("config")
.short('c')
.long("config")
.value_name("FILE")
.help("Sets a custom config file")
.takes_value(true);
get_logging_args().into_iter().chain(vec![config]).collect()
}

fn get_logging_args() -> Vec<Arg<'static, 'static>> {
fn get_logging_args() -> Vec<Arg<'static>> {
[
Arg::with_name("log-level")
Arg::new("log-level")
.long("log-level")
.possible_values(&["error", "warn", "info", "debug", "trace", "off"])
.help("Log level [default: info]")
.global(true)
.takes_value(true),
Arg::with_name("trace")
Arg::new("trace")
.long("trace")
.help("Log ultra-verbose (trace level) information")
.global(true)
.takes_value(false),
Arg::with_name("silent")
Arg::new("silent")
.long("silent")
.help("Suppress all output")
.global(true)
Expand Down
6 changes: 3 additions & 3 deletions flock-cli/src/fsql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
use anyhow::{anyhow, Result};
use benchmarks::rainbow_println;
use clap::{App, ArgMatches, SubCommand};
use clap::{App, ArgMatches};
use rustyline::Editor;

pub fn command(_: &ArgMatches) -> Result<()> {
futures::executor::block_on(fsql())
}

pub fn command_args() -> App<'static, 'static> {
SubCommand::with_name("fsql").about("The terminal-based front-end to Flock")
pub fn command_args() -> App<'static> {
App::new("fsql").about("The terminal-based front-end to Flock")
}

/// The main entry point for fsql.
Expand Down
25 changes: 13 additions & 12 deletions flock-cli/src/lambda.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use anyhow::{Ok, Result};
use benchmarks::rainbow_println;
use clap::{App, Arg, ArgMatches, SubCommand};
use clap::{App, Arg, ArgMatches};
use rusoto_core::Region;
use rusoto_lambda::{DeleteFunctionRequest, Lambda, LambdaClient, ListFunctionsRequest};

Expand All @@ -33,33 +33,34 @@ pub fn command(matches: &ArgMatches) -> Result<()> {
Ok(())
}

pub fn command_args() -> App<'static, 'static> {
SubCommand::with_name("lambda")
pub fn command_args() -> App<'static> {
App::new("lambda")
.about("The AWS Lambda Tool for Flock")
.arg(
Arg::with_name("delete function")
.short("d")
Arg::new("delete function")
.short('d')
.long("delete")
.value_name("FUNCTION_NAME")
.value_name("function name")
.help("Deletes a lambda function")
.takes_value(true),
)
.arg(
Arg::with_name("delete all functions")
.short("D")
Arg::new("delete all functions")
.short('D')
.long("delete-all")
.help("Deletes all lambda functions"),
)
.arg(
Arg::with_name("list functions")
.short("l")
Arg::new("list functions")
.short('l')
.long("list")
.value_name("function name's substring/pattern")
.help("Lists all lambda functions (-l all, or a function name)")
.takes_value(true),
)
.arg(
Arg::with_name("list all functions")
.short("L")
Arg::new("list all functions")
.short('L')
.long("list-all")
.help("Lists all lambda functions"),
)
Expand Down
50 changes: 27 additions & 23 deletions flock-cli/src/nexmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,85 +13,89 @@

//! This crate runs the NexMark Benchmark on cloud function services.
use anyhow::{anyhow, bail, Context as _, Result};
use anyhow::{anyhow, Context as _, Ok, Result};
use benchmarks::{nexmark_benchmark, rainbow_println, NexmarkBenchmarkOpt};
use clap::{App, AppSettings, Arg, ArgMatches, SubCommand};
use clap::{App, AppSettings, Arg, ArgMatches};
use log::warn;

pub fn command(matches: &ArgMatches) -> Result<()> {
let (command, matches) = match matches.subcommand() {
(command, Some(matches)) => (command, matches),
(_, None) => unreachable!(),
Some((command, matches)) => (command, matches),
None => unreachable!(),
};

match command {
"run" => run(matches),
_ => bail!(matches.usage().to_owned()),
_ => {
warn!("{} command is not implemented", command);
Ok(())
}
}
.with_context(|| anyhow!("{} command failed", command))?;

Ok(())
}

pub fn command_args() -> App<'static, 'static> {
SubCommand::with_name("nexmark")
pub fn command_args() -> App<'static> {
App::new("nexmark")
.about("The NEXMark Benchmark Tool")
.setting(AppSettings::SubcommandRequired)
.subcommand(run_args())
}

fn run_args() -> App<'static, 'static> {
SubCommand::with_name("run")
fn run_args() -> App<'static> {
App::new("run")
.about("Runs the NEXMark Benchmark")
.arg(
Arg::with_name("query number")
.short("q")
Arg::new("query number")
.short('q')
.long("query")
.help("Sets the NEXMark benchmark query number [0-12]")
.takes_value(true)
.default_value("3"),
)
.arg(
Arg::with_name("duration")
.short("s")
Arg::new("duration")
.short('s')
.long("seconds")
.help("Runs the NEXMark benchmark for a number of seconds")
.takes_value(true)
.default_value("20"),
)
.arg(
Arg::with_name("data generators")
.short("g")
Arg::new("data generators")
.short('g')
.long("generators")
.help("Runs the NEXMark benchmark with a number of data generators")
.takes_value(true)
.default_value("1"),
)
.arg(
Arg::with_name("events per second")
.short("e")
Arg::new("events per second")
.short('e')
.long("events-per-second")
.help("Runs the NEXMark benchmark with a number of events per second")
.takes_value(true)
.default_value("1000"),
)
.arg(
Arg::with_name("data sink type")
.short("t")
Arg::new("data sink type")
.short('t')
.long("data-sink-type")
.help("Runs the NEXMark benchmark with a data sink type")
.takes_value(true)
.possible_values(&["sqs", "s3", "dynamodb", "efs", "blackhole"])
.default_value("blackhole"),
)
.arg(
Arg::with_name("async type")
.short("a")
Arg::new("async type")
.short('a')
.long("async-type")
.help("Runs the NEXMark benchmark with async function invocations"),
)
.arg(
Arg::with_name("memory size")
.short("m")
Arg::new("memory size")
.short('m')
.long("memory-size")
.help("Sets the memory size (MB) for the worker function")
.takes_value(true)
Expand Down
14 changes: 9 additions & 5 deletions flock-cli/src/repl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ use crate::nexmark;
use crate::s3;
use crate::ysb;
use anyhow::Context as _;
use anyhow::{anyhow, bail, Result};
use anyhow::{anyhow, Result};
use clap::{crate_version, App, AppSettings};
use log::warn;

#[tokio::main]
pub async fn main() -> Result<()> {
Expand All @@ -29,7 +30,7 @@ pub async fn main() -> Result<()> {
.about("Command Line Interactive Contoller for Flock")
.version(crate_version!())
.setting(AppSettings::SubcommandRequired)
.setting(AppSettings::GlobalVersion)
.setting(AppSettings::PropagateVersion)
.author("UMD Database Group")
.args(&args::get_args())
.subcommand(nexmark::command_args())
Expand All @@ -40,8 +41,8 @@ pub async fn main() -> Result<()> {

let global_matches = app_cli.get_matches();
let (command, matches) = match global_matches.subcommand() {
(command, Some(matches)) => (command, matches),
(_, None) => unreachable!(),
Some((command, matches)) => (command, matches),
None => unreachable!(),
};

args::get_logging(&global_matches, matches)?.init();
Expand All @@ -52,7 +53,10 @@ pub async fn main() -> Result<()> {
"upload" => s3::command(matches),
"lambda" => lambda::command(matches),
"fsql" => fsql::command(matches),
_ => bail!(matches.usage().to_owned()),
_ => {
warn!("{} command is not implemented", command);
Ok(())
}
}
.with_context(|| anyhow!("{} command failed", command))?;

Expand Down
14 changes: 7 additions & 7 deletions flock-cli/src/s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use anyhow::{bail, Result};
use benchmarks::rainbow_println;
use clap::{App, Arg, ArgMatches, SubCommand};
use clap::{App, Arg, ArgMatches};
use ini::Ini;
use lazy_static::lazy_static;
use rusoto_core::Region;
Expand Down Expand Up @@ -44,20 +44,20 @@ pub fn command(matches: &ArgMatches) -> Result<()> {
Ok(())
}

pub fn command_args() -> App<'static, 'static> {
SubCommand::with_name("upload")
pub fn command_args() -> App<'static> {
App::new("upload")
.about("Uploads a function code to AWS S3")
.arg(
Arg::with_name("code path")
.short("p")
Arg::new("code path")
.short('p')
.long("path")
.value_name("FILE")
.help("Sets the path to the function code")
.takes_value(true),
)
.arg(
Arg::with_name("s3 key")
.short("k")
Arg::new("s3 key")
.short('k')
.long("key")
.value_name("S3_KEY")
.help("Sets the S3 key to upload the function code to")
Expand Down
Loading

0 comments on commit ea8006b

Please sign in to comment.