aboutsummaryrefslogtreecommitdiff
path: root/console/src/bin
diff options
context:
space:
mode:
authorWeicao-CatilGrass <1992414357@qq.com>2025-06-09 12:06:15 +0800
committerWeicao-CatilGrass <1992414357@qq.com>2025-06-09 12:06:15 +0800
commit0d8761e5f907d173c40a2a44f3a1d8d8ce5a2f6e (patch)
treec4f851afd3e0951e43a2092176cec78ea9bc3773 /console/src/bin
parent44d61a897519e4f180d981d2c0846b9f59ef55c8 (diff)
.
Diffstat (limited to 'console/src/bin')
-rw-r--r--console/src/bin/padc.rs18
1 files changed, 15 insertions, 3 deletions
diff --git a/console/src/bin/padc.rs b/console/src/bin/padc.rs
index 720cbea..3323de7 100644
--- a/console/src/bin/padc.rs
+++ b/console/src/bin/padc.rs
@@ -7,6 +7,7 @@ use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::env::current_dir;
use std::fs::File;
+use std::io;
use std::io::{BufReader, Write};
use std::net::SocketAddr;
use std::path::PathBuf;
@@ -15,6 +16,7 @@ use std::str::FromStr;
use std::sync::{Arc, Mutex};
use std::sync::atomic::Ordering::SeqCst;
use std::time::Duration;
+use clap_complete::{generate, Shell};
use log::{info, LevelFilter};
use tokio::select;
use tokio::signal::ctrl_c;
@@ -31,8 +33,8 @@ use nogamepads_core::service::tcp_network::pad_client::structs::PadClientNetwork
use nogamepads_core::service::tcp_network::pad_server::structs::PadServerNetwork;
#[derive(Parser, Debug)]
-#[command(author, version, about, long_about = None)]
-struct ConsoleCli {
+#[command(version, color = ColorChoice::Auto)]
+struct Padc {
#[command(subcommand)]
command: Commands,
}
@@ -40,6 +42,11 @@ struct ConsoleCli {
#[derive(Subcommand, Debug)]
enum Commands {
+ GenerateCompletion {
+ #[arg(value_enum)]
+ shell: Shell,
+ },
+
#[command(subcommand, about = "Manage accounts")]
Account(AccountCommands),
@@ -257,10 +264,15 @@ struct LocalControllerData {
}
fn main () {
- let cli = ConsoleCli::parse();
+ let cli = Padc::parse();
let mut data = read();
match cli.command {
+ Commands::GenerateCompletion {shell} => {
+ let mut cmd = Padc::command();
+ generate(shell, &mut cmd.clone(), "padc", &mut io::stdout());
+ }
+
Commands::Account(cmds) => {
match cmds {
AccountCommands::Add(args) => {