fix cli
This commit is contained in:
parent
5b035fe12c
commit
14b4f08147
3 changed files with 50 additions and 29 deletions
32
docs/cli-arguments.md
Normal file
32
docs/cli-arguments.md
Normal file
|
@ -0,0 +1,32 @@
|
|||
# CLI Arguments
|
||||
|
||||
Add `-h` or `--help` to any subcommand to view its help.
|
||||
|
||||
## Run (`run`)
|
||||
|
||||
```txt
|
||||
Usage: gregory run [OPTIONS]
|
||||
```
|
||||
|
||||
**Options:**
|
||||
|
||||
- `-c`, `--config`: Path to the config file; default: `gregory.yml`
|
||||
<!-- - `-d`, `--daemonize`: Whether to daemonize the program - not yet supported -->
|
||||
|
||||
## Generate shell completions `gen-completion`
|
||||
|
||||
```txt
|
||||
Usage: gregory gen-completion [OPTIONS] <COMMAND>
|
||||
```
|
||||
|
||||
**Commands:**
|
||||
|
||||
- bash
|
||||
- zsh
|
||||
- fish
|
||||
- elvish
|
||||
- powershell
|
||||
|
||||
**Options:**
|
||||
|
||||
- `-b`, `--binary-name`: The name of the binary; default: `gregory`
|
32
src/cli.rs
32
src/cli.rs
|
@ -13,36 +13,26 @@ pub enum Commands {
|
|||
GenCompletion {
|
||||
#[command(subcommand)]
|
||||
shell: ShellCommands,
|
||||
#[arg(short, long, default_value = "gregory")]
|
||||
binary_name: String,
|
||||
},
|
||||
///Runs it
|
||||
Run {
|
||||
#[arg(short, long)]
|
||||
///Path to the config file
|
||||
#[arg(short, long, default_value = "gregory.yml")]
|
||||
config: String,
|
||||
/* Not yet supported
|
||||
#[arg(short, long)]
|
||||
daemonize: bool,
|
||||
*/
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Subcommand, Debug)]
|
||||
pub enum ShellCommands {
|
||||
Bash {
|
||||
#[arg(short, long, default_value = "gregory")]
|
||||
binary_name: String,
|
||||
},
|
||||
Zsh {
|
||||
#[arg(short, long, default_value = "gregory")]
|
||||
binary_name: String,
|
||||
},
|
||||
Fish {
|
||||
#[arg(short, long, default_value = "gregory")]
|
||||
binary_name: String,
|
||||
},
|
||||
Elvish {
|
||||
#[arg(short, long, default_value = "gregory")]
|
||||
binary_name: String,
|
||||
},
|
||||
PowerShell {
|
||||
#[arg(short, long, default_value = "gregory")]
|
||||
binary_name: String,
|
||||
},
|
||||
Bash,
|
||||
Zsh,
|
||||
Fish,
|
||||
Elvish,
|
||||
Powershell,
|
||||
}
|
||||
|
|
15
src/main.rs
15
src/main.rs
|
@ -12,26 +12,25 @@ fn main() {
|
|||
let cli = Cli::parse();
|
||||
|
||||
match cli.command {
|
||||
Commands::GenCompletion { shell } => match shell {
|
||||
ShellCommands::Bash { binary_name } => {
|
||||
Commands::GenCompletion { shell, binary_name } => match shell {
|
||||
ShellCommands::Bash => {
|
||||
generate(Bash, &mut Cli::command(), binary_name, &mut stdout());
|
||||
}
|
||||
ShellCommands::Zsh { binary_name } => {
|
||||
ShellCommands::Zsh => {
|
||||
generate(Zsh, &mut Cli::command(), binary_name, &mut stdout());
|
||||
}
|
||||
ShellCommands::Fish { binary_name } => {
|
||||
ShellCommands::Fish => {
|
||||
generate(Fish, &mut Cli::command(), binary_name, &mut stdout());
|
||||
}
|
||||
ShellCommands::Elvish { binary_name } => {
|
||||
ShellCommands::Elvish => {
|
||||
generate(Elvish, &mut Cli::command(), binary_name, &mut stdout());
|
||||
}
|
||||
ShellCommands::PowerShell { binary_name } => {
|
||||
ShellCommands::Powershell => {
|
||||
generate(PowerShell, &mut Cli::command(), binary_name, &mut stdout());
|
||||
}
|
||||
},
|
||||
Commands::Run { config, daemonize } => {
|
||||
Commands::Run { config} => {
|
||||
println!("{}", config);
|
||||
println!("{}", daemonize)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue