feat: rename commands and remove aliases in favour of completion
BREAKING CHANGE: changed commands as follows D -> Docker Dc -> Compose Dj -> Django Pg -> Postgres
This commit is contained in:
parent
61e7556997
commit
de5e6b4d10
|
@ -19,25 +19,25 @@ pub enum Commands {
|
|||
},
|
||||
|
||||
/// Docker related subcommands
|
||||
D {
|
||||
Docker {
|
||||
#[command(subcommand)]
|
||||
command: Docker,
|
||||
},
|
||||
|
||||
/// Docker compose related subcommands
|
||||
Dc {
|
||||
Compose {
|
||||
#[command(subcommand)]
|
||||
command: DockerCompose,
|
||||
},
|
||||
|
||||
/// Docker compose related subcommands
|
||||
Dj {
|
||||
Django {
|
||||
#[command(subcommand)]
|
||||
command: Django,
|
||||
},
|
||||
|
||||
/// Postgres related subcommands
|
||||
Pg {
|
||||
Postgres {
|
||||
#[command(subcommand)]
|
||||
command: Postgres,
|
||||
},
|
||||
|
|
|
@ -7,7 +7,6 @@ use clap::Parser;
|
|||
#[derive(Parser, Debug)]
|
||||
pub enum Django {
|
||||
/// Prepare empty management command 'command' in app 'app'.
|
||||
#[clap(alias("mc"))]
|
||||
MakeCommand {
|
||||
#[arg(value_enum)]
|
||||
app: PathBuf,
|
||||
|
@ -16,24 +15,20 @@ pub enum Django {
|
|||
},
|
||||
|
||||
/// Run Django's manage.py makemigrations.
|
||||
#[clap(alias("mm"))]
|
||||
Makemigrations,
|
||||
|
||||
/// Pass arguments to Django's manage.py.
|
||||
#[clap(alias("m"))]
|
||||
Manage {
|
||||
#[arg(value_enum)]
|
||||
rest: Vec<String>,
|
||||
},
|
||||
|
||||
/// Run Django's manage.py migrate.
|
||||
#[clap(alias("mg"))]
|
||||
Migrate {
|
||||
#[arg(value_enum)]
|
||||
rest: Vec<String>,
|
||||
},
|
||||
|
||||
/// Run Django's manage.py shell.
|
||||
#[clap(alias("s"))]
|
||||
Shell,
|
||||
}
|
||||
|
|
|
@ -3,6 +3,5 @@ use clap::Parser;
|
|||
#[derive(Parser, Debug)]
|
||||
pub enum Docker {
|
||||
/// Stop all containers via `docker stop $(docker ps -q)`
|
||||
#[clap(alias("sa"))]
|
||||
StopAll,
|
||||
}
|
||||
|
|
|
@ -6,30 +6,23 @@ use clap::Subcommand;
|
|||
#[derive(Subcommand, Debug)]
|
||||
pub enum DockerCompose {
|
||||
/// Build containers.
|
||||
#[clap(alias("b"))]
|
||||
Build,
|
||||
|
||||
/// Down containers.
|
||||
#[clap(alias("d"))]
|
||||
Down,
|
||||
|
||||
/// Stop, build and start containers.
|
||||
#[clap(alias("rb"))]
|
||||
Rebuild,
|
||||
|
||||
/// Stop and start containers.
|
||||
#[clap(alias("rs"))]
|
||||
Restart,
|
||||
|
||||
/// Start containers.
|
||||
#[clap(alias("st"))]
|
||||
Start,
|
||||
|
||||
/// Stop containers.
|
||||
#[clap(alias("s"))]
|
||||
Stop,
|
||||
|
||||
/// Up containers.
|
||||
#[clap(alias("u"))]
|
||||
Up,
|
||||
}
|
||||
|
|
|
@ -5,14 +5,12 @@ use clap::Subcommand;
|
|||
#[derive(Subcommand, Debug)]
|
||||
pub enum Postgres {
|
||||
/// Import dump via pg_restore
|
||||
#[clap(alias("i"))]
|
||||
Import {
|
||||
#[arg(value_enum)]
|
||||
path: PathBuf,
|
||||
},
|
||||
|
||||
/// Dump via pg_dump with format=c
|
||||
#[clap(alias("d"))]
|
||||
Dump {
|
||||
#[arg(value_enum)]
|
||||
path: PathBuf,
|
||||
|
|
|
@ -22,10 +22,10 @@ fn main() -> Result<()> {
|
|||
);
|
||||
Ok(())
|
||||
}
|
||||
cli::Commands::D { command } => match command {
|
||||
cli::Commands::Docker { command } => match command {
|
||||
cli::Docker::StopAll => scripts::docker::stop_all(),
|
||||
},
|
||||
cli::Commands::Dc { command } => match command {
|
||||
cli::Commands::Compose { command } => match command {
|
||||
cli::DockerCompose::Build => scripts::docker_compose::build(),
|
||||
cli::DockerCompose::Down => scripts::docker_compose::down(),
|
||||
cli::DockerCompose::Rebuild => scripts::docker_compose::rebuild(),
|
||||
|
@ -34,14 +34,14 @@ fn main() -> Result<()> {
|
|||
cli::DockerCompose::Stop => scripts::docker_compose::stop(),
|
||||
cli::DockerCompose::Up => scripts::docker_compose::up(),
|
||||
},
|
||||
cli::Commands::Dj { command } => match command {
|
||||
cli::Commands::Django { command } => match command {
|
||||
cli::Django::MakeCommand { app, name } => scripts::django::make_command(&app, &name),
|
||||
cli::Django::Makemigrations => scripts::django::makemigrations(),
|
||||
cli::Django::Manage { rest } => scripts::django::manage(&rest),
|
||||
cli::Django::Migrate { rest } => scripts::django::migrate(&rest),
|
||||
cli::Django::Shell => scripts::django::shell(),
|
||||
},
|
||||
cli::Commands::Pg { command } => match command {
|
||||
cli::Commands::Postgres { command } => match command {
|
||||
cli::Postgres::Import { path } => scripts::postgres::import(&path),
|
||||
cli::Postgres::Dump { path } => scripts::postgres::dump(&path),
|
||||
},
|
||||
|
|
|
@ -68,4 +68,3 @@ pub fn migrate(rest: &[String]) -> Result<()> {
|
|||
|
||||
manage(&full_rest)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue