Skip to content

Commit

Permalink
feat: Mise en place autocompletion
Browse files Browse the repository at this point in the history
  • Loading branch information
batleforc committed Jan 4, 2025
1 parent b070e6c commit 9070ab4
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ Inside of this module there will be multiple categories of commands that will be
- `dev_cli code` - Commands that are related to vscode manipulation (Open che workspace in vscode desktop)
- `dev_cli workspace` - Commands that are related to workspace manipulation (Info/Get/List/Start/Stop/...)
- `dev_cli shell` - Commands that are related to shell manipulation (ItShell/ExecShell/...)
- `dev_cli completion` - Commands that are related to completion manipulation (Bash/Zsh/...)

#### Code
#### Code - Working

- `dev_cli code open` - Open the current workspace in vscode desktop
- `dev_cli code check` - Check if the needed vscode extension are installed and install them if needed

#### Workspace
#### Workspace - TODO

- `dev_cli workspace info` - Output workspace info, and if run directly in a workspace, output the current workspace info, either ask the user to choose a workspace (output could be json or yaml)
- `dev_cli workspace get` - Get a workspace by name, by default the current if in one
Expand All @@ -32,11 +33,15 @@ Inside of this module there will be multiple categories of commands that will be
- `dev_cli workspace restart` - Restart a workspace by name
- `dev_cli workspace restart_from_local` - Restart from local devfile

#### Shell
#### Shell - TODO

- `dev_cli shell it` - Start an interactive shell in the current workspace
- `dev_cli shell exec` - Execute a command in the current workspace

#### Completion - TODO

- `dev_cli completion -s $TERMINAL_KIND` - Output $TERMINAL_KIND completion script

## MonoRepo

Based on the [Rust NX](https://github.com/cammisuli/monodon/tree/main/packages/rust) template.
Expand Down
1 change: 1 addition & 0 deletions apps/dev_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ tracing = { workspace = true }
k8s-openapi = { workspace = true }
kube = { workspace = true }
clap = { version = "4.5.23", features = ["derive"] }
clap_complete = "4.5.40"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
12 changes: 11 additions & 1 deletion apps/dev_cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use clap::{Parser, Subcommand};
use clap::{CommandFactory, Parser, Subcommand};
use clap_complete::{generate, Shell};
use level::VerboseSwapLevel;
use tool_tracing::{init, level::VerboseLevel, tracing_kind::Tracing};

Expand Down Expand Up @@ -40,6 +41,11 @@ pub enum Commands {
#[command(subcommand)]
code: Option<code::Code>,
},
/// Generate completion scripts for your shell
Completion {
#[arg(short, long)]
shell: Shell,
},
}

#[tokio::main]
Expand Down Expand Up @@ -79,6 +85,10 @@ async fn main() {
Some(Commands::Code { code }) => {
code.as_ref().unwrap().run().await;
}
Some(Commands::Completion { shell }) => {
let mut cmd = Cli::command();
generate(*shell, &mut cmd, "dev_cli", &mut std::io::stdout());
}
None => tracing::info!("No command provided"),
};
}

0 comments on commit 9070ab4

Please sign in to comment.