pub use clap::{Parser, Subcommand, Args};
#[derive(Parser, Debug)]
#[command(name="cdp", version)]
#[command(
about="CDP - This CLI helps you quickly navigate to a directory and perform useful operations on it.",
long_about="
CDP stands for CD Program, where 'cd' refers to the directory-changing command in Unix-like shells and PowerShell.
This CLI helps you quickly navigate to a directory and perform useful operations on it."
)]
pub struct Cli {
#[command(subcommand)]
pub command: Option<Commands>,
}
#[derive(Subcommand, Debug)]
pub enum Commands {
Setup(SetupCommand),
#[command(alias="g")]
General(GeneralCommand),
#[command(alias="alias")]
Aliases(AliasesCommand),
#[command(alias="cmdal", alias="cmd-alias")]
CommandAliases(CmdAliasesCommand),
#[command(alias="cp")]
CreateProject(CPCommand),
}
#[derive(Args, Debug)]
pub struct SetupCommand {
#[arg(long, short='v')]
pub verbose: bool,
}
#[derive(Args, Debug)]
pub struct GeneralCommand {
pub path: String,
#[arg(long)]
pub ls: bool,
#[arg(long, short='E')]
pub editor: Option<Editors>,
#[arg(long, hide=true, conflicts_with="editor")]
pub vsc: bool,
#[cfg_attr(windows, doc = "Make the command start from 'USER' ($HOME)")]
#[cfg_attr(unix, doc = "Make the command start from 'HOME' (~/)")]
#[arg(short='C', long, conflicts_with="alias", hide = true)]
pub current_user: bool,
#[arg(long, alias="al", hide = true)]
pub alias: bool,
}
#[derive(Args, Debug)]
pub struct AliasesCommand {
#[arg(value_name="PATH", required_unless_present_any=["list", "edit", "remove"])]
pub path: Option<String>,
#[cfg_attr(windows, doc = "It will be stored on 'cdpaliases.txt' file (file path: '%USERPROFILE%\\.cdputils\\cdpaliases.txt')")]
#[cfg_attr(unix, doc = "It will be stored on 'cdpaliases.txt' file (file path: '~/.cdputils/cdpaliases.txt')")]
#[arg(value_name="ALIAS", required_unless_present_any=["list", "edit", "remove"])]
pub alias: Option<String>,
#[cfg_attr(windows, doc = r"'%USERPROFILE%\.cdputils\cdpaliases.txt'")]
#[cfg_attr(unix, doc = "'~/.cdputils/cdpaliases.txt'")]
#[arg(long, short='l', alias="ls", conflicts_with="alias")]
pub list: bool,
#[cfg_attr(windows, doc = r"'%USERPROFILE%\.cdputils\cdpaliases.txt'")]
#[cfg_attr(unix, doc = "'~/.cdputils/cdpaliases.txt'")]
#[arg(long, short='r', alias="rm", conflicts_with="edit")]
pub remove: Option<String>,
#[cfg_attr(windows, doc = r"'%USERPROFILE%\.cdputils\cdpaliases.txt'")]
#[cfg_attr(unix, doc = "'~/.cdputils/cdpaliases.txt'")]
#[arg(long, short='e')]
pub edit: Option<String>,
}
#[derive(Args, Debug)]
pub struct CmdAliasesCommand {
#[cfg_attr(windows, doc = "It will be stored on 'cdp_cmdaliases.txt' file (file path: '%USERPROFILE%\\.cdputils\\cdp_cmdaliases.txt')")]
#[cfg_attr(unix, doc = "It will be stored on 'cdp_cmdaliases.txt' file (file path: '~/.cdputils/cdp_cmdaliases.txt')")]
#[arg(value_name="COMMAND", required_unless_present_any=["list", "edit", "remove", "execute"])]
pub cmd: Option<String>,
#[cfg_attr(windows, doc = "It will be stored on 'cdp_cmdaliases.txt' file (file path: '%USERPROFILE%\\.cdputils\\cdp_cmdaliases.txt')")]
#[cfg_attr(unix, doc = "It will be stored on 'cdp_cmdaliases.txt' file (file path: '~/.cdputils/cdp_cmdaliases.txt')")]
#[arg(value_name="ALIAS", required_unless_present_any=["list", "edit", "remove", "execute"])]
pub alias: Option<String>,
#[arg(long, short='E', alias="exe", required_unless_present_any=["list", "edit", "remove", "cmd", "alias"])]
pub execute: Option<String>,
#[cfg_attr(windows, doc = r"'%USERPROFILE%\.cdputils\cdp_cmdaliases.txt'")]
#[cfg_attr(unix, doc = "'~/.cdputils/cdp_cmdaliases.txt'")]
#[arg(long, short='l', alias="ls", conflicts_with="cmd")]
pub list: bool,
#[cfg_attr(windows, doc = r"'%USERPROFILE%\.cdputils\cdp_cmdaliases.txt'")]
#[cfg_attr(unix, doc = "'~/.cdputils/cdp_cmdaliases.txt'")]
#[arg(long, short='r', alias="rm", conflicts_with="edit")]
pub remove: Option<String>,
#[cfg_attr(windows, doc = r"'%USERPROFILE%\.cdputils\cdp_cmdaliases.txt'")]
#[cfg_attr(unix, doc = "'~/.cdputils/cdp_cmdaliases.txt'")]
#[arg(long, short='e')]
pub edit: Option<String>,
}
#[derive(Args, Debug)]
pub struct CPCommand {
#[cfg_attr(windows, doc = "Will be created in '%USERPROFILE%/.cdputils/projects'")]
#[cfg_attr(unix, doc = "Will be created in '~/.cdputils/projects'")]
pub name: String,
pub lang: Langs,
#[arg(long, alias="al")]
pub alias: Option<String>,
#[cfg_attr(windows, doc = r"such as 'C:\Program Files')")]
#[cfg_attr(unix, doc = "such as root directories (/bin, /usr, /dev, etc...))")]
#[arg(long, short='p')]
pub path: Option<String>,
}
#[derive(Debug, Clone, clap::ValueEnum)]
pub enum Editors {
#[clap(alias="vscode")]
Vsc,
}
#[derive(Debug, Clone, clap::ValueEnum)]
pub enum Langs {
#[clap(alias="rust")]
Rs,
#[clap(alias="javascript", alias="nodejs")]
Js,
#[clap(alias="typescript")]
Ts,
#[clap(alias="python")]
Py,
#[clap(alias="clang")]
C,
#[clap(alias="c++")]
Cpp,
}