use crate::commands;
use crate::error::Result;
use clap::{Args, Parser, Subcommand};
#[derive(Subcommand, Debug, PartialEq)]
pub enum ConfigCommand {
Show,
Edit,
Set(ConfigSetArgs),
DirAdd(DirectoryAddArgs),
DirRm(DirectoryRemoveArgs),
}
#[derive(Args, Debug, PartialEq)]
pub struct ConfigSetArgs {
#[arg(long)]
pub endpoint: Option<String>,
#[arg(long)]
pub backet: Option<String>,
#[arg(long)]
pub part_size: Option<u64>,
#[arg(long)]
pub local_directory_path: Option<String>,
}
#[derive(Args, Debug, PartialEq)]
pub struct DirectoryAddArgs {
pub prefix_file: String,
pub cloud_dir: String,
}
#[derive(Args, Debug, PartialEq)]
pub struct DirectoryRemoveArgs {
pub prefix_file: String,
}
#[derive(Subcommand, Debug, PartialEq)]
pub enum Commands {
Config {
#[command(subcommand)]
command: ConfigCommand,
},
Login,
Run {
#[arg(short, long, default_value_t = false)]
quiet: bool,
},
Schedule { cron: String },
}
#[derive(Parser, Debug, PartialEq)]
#[command(name = "prefixload")]
#[command(about = "TODO ...")]
#[command(version)]
pub struct Cli {
#[command(subcommand)]
command: Commands,
}
impl Cli {
pub fn run(self) -> Result<String> {
match self.command {
Commands::Config { command } => commands::config::run(command),
Commands::Login => commands::login::run(),
Commands::Run { quiet } => commands::run::run(quiet),
Commands::Schedule { cron } => commands::schedule::run(cron.as_ref()),
}
}
pub fn get_command(&self) -> &Commands {
&self.command
}
}