use clap::{ArgAction, Command, arg, command};
pub struct Cli {}
impl Cli {
fn cmd() -> Command {
command!()
.version("0.1.0")
.about("DeepR S3 Operations CLI")
.author("Ngakan Gandhi <ngandhi@pmintl.net")
.bin_name("deepr")
.subcommand(
Command::new("bucket").about("S3 bucket API")
.subcommand(
Command::new("list")
.arg(arg!(-p --pretty "Pretty print output").action(ArgAction::SetTrue))
.arg_required_else_help(true),
)
.subcommand(Command::new("policies").about("S3 bucket policies getter API"))
)
.subcommand(
Command::new("objects").about("S3 objects API").subcommand(
Command::new("list")
.arg(arg!(-b --bucket <VALUE> "input S3 bucket").required(true))
.arg(arg!(-r --prefix <VALUE> "Key prefix").required(true))
.arg(arg!(-m --"last-modified-time" <VALUE> "last modified time of the objects [YYYY-mm-dd HH:MM:SS]")
.required(true)
.default_value("1970-01-01 00:00:00"))
.arg(arg!(-g --predicate <VALUE> "predicate to filter objects [newer, older]")
.required(true)
.default_value("newer"))
.arg(arg!(-v --versions "List objects versions in an S3 bucket"))
.arg(arg!(-p --pretty "Pretty print output").action(ArgAction::SetTrue))
.arg_required_else_help(true),
),
)
}
#[allow(clippy::single_match)]
pub fn run() {
let matches = Cli::cmd().get_matches();
match matches.subcommand() {
Some(("s3", s3_matches)) => match s3_matches.subcommand() {
Some(("bucket", _)) => {
println!("S3 bucket API...");
}
Some(("objects", _)) => {
println!("S3 objects API...");
}
_ => (),
},
_ => (),
}
}
}