[CLI] a warm welcome message included :) (#1417)

* [CLI] a warm welcome message included :)

* Update layout

* update layout
This commit is contained in:
Billy Chan 2023-01-27 12:44:40 +08:00 committed by GitHub
parent 27e2b5c5da
commit 9fbfd06663
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 65 additions and 14 deletions

View File

@ -4,7 +4,10 @@
[package] [package]
name = "sea-orm-cli" name = "sea-orm-cli"
version = "0.10.3" version = "0.10.3"
authors = ["Billy Chan <ccw.billy.123@gmail.com>"] authors = [
"Chris Tsang <chris.2y3@outlook.com>",
"Billy Chan <ccw.billy.123@gmail.com>",
]
edition = "2021" edition = "2021"
description = "Command line utility for SeaORM" description = "Command line utility for SeaORM"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"

View File

@ -1,7 +1,41 @@
use clap::{ArgEnum, ArgGroup, Parser, Subcommand}; use clap::{ArgEnum, ArgGroup, Parser, Subcommand};
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
#[clap(version)] #[clap(
version,
author,
help_template = r#"{before-help}{name} {version}
{about-with-newline}
{usage-heading} {usage}
{all-args}{after-help}
AUTHORS:
{author}
"#,
about = r#"
____ ___ ____ __ __ /\
/ ___| ___ __ _ / _ \ | _ \ | \/ | {.-}
\___ \ / _ \ / _` || | | || |_) || |\/| | ;_.-'\
___) || __/| (_| || |_| || _ < | | | | { _.}_
|____/ \___| \__,_| \___/ |_| \_\|_| |_| \.-' / `,
\ | /
An async & dynamic ORM for Rust \ | ,/
=============================== \|_/
Getting Started!
- documentation: https://www.sea-ql.org/SeaORM
- step-by-step tutorials: https://www.sea-ql.org/sea-orm-tutorial
- integration examples: https://github.com/SeaQL/sea-orm/tree/master/examples
- cookbook: https://www.sea-ql.org/sea-orm-cookbook
Join our Discord server to chat with others in the SeaQL community!
- invitation link: https://discord.com/invite/uCPdDXzbdv
If you like what we do, consider starring, commenting, sharing and contributing!
"#
)]
pub struct Cli { pub struct Cli {
#[clap(action, global = true, short, long, help = "Show debug messages")] #[clap(action, global = true, short, long, help = "Show debug messages")]
pub verbose: bool, pub verbose: bool,
@ -12,13 +46,16 @@ pub struct Cli {
#[derive(Subcommand, PartialEq, Eq, Debug)] #[derive(Subcommand, PartialEq, Eq, Debug)]
pub enum Commands { pub enum Commands {
#[clap(about = "Codegen related commands")] #[clap(
#[clap(arg_required_else_help = true)] about = "Codegen related commands",
arg_required_else_help = true,
display_order = 10
)]
Generate { Generate {
#[clap(subcommand)] #[clap(subcommand)]
command: GenerateSubcommands, command: GenerateSubcommands,
}, },
#[clap(about = "Migration related commands")] #[clap(about = "Migration related commands", display_order = 20)]
Migrate { Migrate {
#[clap( #[clap(
value_parser, value_parser,
@ -63,9 +100,9 @@ you should provide the directory of that submodule.",
#[derive(Subcommand, PartialEq, Eq, Debug)] #[derive(Subcommand, PartialEq, Eq, Debug)]
pub enum MigrateSubcommands { pub enum MigrateSubcommands {
#[clap(about = "Initialize migration directory")] #[clap(about = "Initialize migration directory", display_order = 10)]
Init, Init,
#[clap(about = "Generate a new, empty migration")] #[clap(about = "Generate a new, empty migration", display_order = 20)]
Generate { Generate {
#[clap( #[clap(
value_parser, value_parser,
@ -82,15 +119,21 @@ pub enum MigrateSubcommands {
)] )]
universal_time: bool, universal_time: bool,
}, },
#[clap(about = "Drop all tables from the database, then reapply all migrations")] #[clap(
about = "Drop all tables from the database, then reapply all migrations",
display_order = 30
)]
Fresh, Fresh,
#[clap(about = "Rollback all applied migrations, then reapply all migrations")] #[clap(
about = "Rollback all applied migrations, then reapply all migrations",
display_order = 40
)]
Refresh, Refresh,
#[clap(about = "Rollback all applied migrations")] #[clap(about = "Rollback all applied migrations", display_order = 50)]
Reset, Reset,
#[clap(about = "Check the status of all migrations")] #[clap(about = "Check the status of all migrations", display_order = 60)]
Status, Status,
#[clap(about = "Apply pending migrations")] #[clap(about = "Apply pending migrations", display_order = 70)]
Up { Up {
#[clap( #[clap(
value_parser, value_parser,
@ -100,14 +143,19 @@ pub enum MigrateSubcommands {
)] )]
num: Option<u32>, num: Option<u32>,
}, },
#[clap(value_parser, about = "Rollback applied migrations")] #[clap(
value_parser,
about = "Rollback applied migrations",
display_order = 80
)]
Down { Down {
#[clap( #[clap(
value_parser, value_parser,
short, short,
long, long,
default_value = "1", default_value = "1",
help = "Number of applied migrations to be rolled back" help = "Number of applied migrations to be rolled back",
display_order = 90
)] )]
num: u32, num: u32,
}, },