1use clap::{ArgAction, Command, arg, command};
3pub struct Cli {}
4
5impl Cli {
6 fn cmd() -> Command {
7 command!()
8 .version("0.1.0")
9 .about("DeepR S3 Operations CLI")
10 .author("Ngakan Gandhi <ngandhi@pmintl.net")
11 .bin_name("deepr")
12 .subcommand(
13 Command::new("bucket").about("S3 bucket API")
14 .subcommand(
15 Command::new("list")
16 .arg(arg!(-p --pretty "Pretty print output").action(ArgAction::SetTrue))
17 .arg_required_else_help(true),
18 )
19 .subcommand(Command::new("policies").about("S3 bucket policies getter API"))
20 )
21 .subcommand(
22 Command::new("objects").about("S3 objects API").subcommand(
23 Command::new("list")
24 .arg(arg!(-b --bucket <VALUE> "input S3 bucket").required(true))
25 .arg(arg!(-r --prefix <VALUE> "Key prefix").required(true))
26 .arg(arg!(-m --"last-modified-time" <VALUE> "last modified time of the objects [YYYY-mm-dd HH:MM:SS]")
27 .required(true)
28 .default_value("1970-01-01 00:00:00"))
29 .arg(arg!(-g --predicate <VALUE> "predicate to filter objects [newer, older]")
30 .required(true)
31 .default_value("newer"))
32 .arg(arg!(-v --versions "List objects versions in an S3 bucket"))
33 .arg(arg!(-p --pretty "Pretty print output").action(ArgAction::SetTrue))
34 .arg_required_else_help(true),
35 ),
36 )
37 }
38
39 #[allow(clippy::single_match)]
40 pub fn run() {
41 let matches = Cli::cmd().get_matches();
42 match matches.subcommand() {
43 Some(("s3", s3_matches)) => match s3_matches.subcommand() {
44 Some(("bucket", _)) => {
45 println!("S3 bucket API...");
46 }
47 Some(("objects", _)) => {
48 println!("S3 objects API...");
49 }
50 _ => (),
51 },
52 _ => (),
53 }
54 }
55}