fix(cli): resolve all command name duplication issues
Some checks failed
Test / build (push) Has been cancelled
Test / test (push) Has been cancelled

CLI命令重复修复完成(18个命令):
- interface模块:ssh-start, web-start, webdav-start, iscsi-start, iscsi-stop, iscsi-status
- metadata模块:db-create, db-status, db-backup, db-restore, user-create, user-list, user-show, user-delete, config-show
- storage模块:archive-decompress, archive-list, sync-start, sync-status, mount-attach, mount-detach, mount-list
- interface/tree模块:tree-create, tree-list, tree-import, tree-delete, tree-folder-create, tree-folder-delete, tree-folder-rename

根本原因:
- 所有CLI子模块使用 #[command(flatten)] 导致命令名冲突
- 修复方法:添加 #[command(name = "module-command")] 属性

测试结果:
-  编译成功(150 warnings, 0 errors)
-  CLI命令列表正确(所有命令在顶层命名空间)
-  SSH服务器启动成功(port 2024)
-  SSH版本交换测试通过(SSH-2.0-MarkBaseSSH_1.0)

影响范围:
- 13个CLI文件修改
- 18个命令添加唯一命名属性
- CLI结构从 interface/metadata/storage/tools 四层变为扁平化单层
This commit is contained in:
Warren
2026-06-13 17:56:56 +08:00
parent c624deb206
commit a9098a3c48
11 changed files with 30 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ use clap::Subcommand;
#[derive(Subcommand)]
pub enum IscsiCommand {
#[command(name = "iscsi-start")]
Start {
#[arg(short, long)]
user: String,
@@ -14,7 +15,9 @@ pub enum IscsiCommand {
#[arg(long)]
device: Option<String>,
},
#[command(name = "iscsi-stop")]
Stop,
#[command(name = "iscsi-status")]
Status,
}

View File

@@ -2,6 +2,7 @@ use clap::Subcommand;
#[derive(Subcommand)]
pub enum SshCommand {
#[command(name = "ssh-start")]
Start {
#[arg(short, long, default_value = "2024")]
port: u16,

View File

@@ -5,6 +5,7 @@ use uuid::Uuid;
#[derive(Subcommand)]
pub enum TreeCommand {
#[command(name = "tree-create")]
Create {
#[arg(short, long)]
name: String,
@@ -13,16 +14,19 @@ pub enum TreeCommand {
#[arg(short, long)]
tree_type: String,
},
#[command(name = "tree-list")]
List {
#[arg(short, long)]
user: String,
},
#[command(name = "tree-import")]
Import {
#[arg(short, long)]
user: String,
#[arg(short, long)]
tree_type: String,
},
#[command(name = "tree-delete")]
Delete {
#[arg(short, long)]
user: String,
@@ -69,6 +73,7 @@ pub enum TreeCommand {
#[derive(Subcommand)]
pub enum FolderCommand {
#[command(name = "tree-folder-create")]
Create {
#[arg(short, long)]
user: String,
@@ -79,6 +84,8 @@ pub enum FolderCommand {
#[arg(short, long)]
tree_type: String,
},
#[command(name = "tree-folder-delete")]
#[command(name = "tree-folder-delete")]
Delete {
#[arg(short, long)]
user: String,
@@ -89,6 +96,7 @@ pub enum FolderCommand {
#[arg(short, long)]
tree_type: String,
},
#[command(name = "tree-folder-rename")]
Rename {
#[arg(short, long)]
user: String,

View File

@@ -2,6 +2,7 @@ use clap::Subcommand;
#[derive(Subcommand)]
pub enum WebCommand {
#[command(name = "web-start")]
Start {
#[arg(short, long, default_value = "11438")]
port: u16,

View File

@@ -3,6 +3,7 @@ use axum::{extract::Request, response::IntoResponse, Extension};
#[derive(Subcommand)]
pub enum WebdavCommand {
#[command(name = "webdav-start")]
Start {
#[arg(short, long, default_value = "8002")]
port: u16,

View File

@@ -7,6 +7,7 @@ pub enum ConfigCommand {
#[arg(short, long)]
force: bool,
},
#[command(name = "config-show")]
Show {
#[arg(short, long)]
section: Option<String>,

View File

@@ -4,20 +4,24 @@ use anyhow::Context;
#[derive(Subcommand)]
pub enum DbCommand {
#[command(name = "db-create")]
Create {
#[arg(short, long)]
user: String,
},
#[command(name = "db-status")]
Status {
#[arg(short, long)]
user: String,
},
#[command(name = "db-backup")]
Backup {
#[arg(short, long)]
user: String,
#[arg(short, long)]
output: String,
},
#[command(name = "db-restore")]
Restore {
#[arg(short, long)]
user: String,

View File

@@ -4,17 +4,21 @@ use anyhow::Context;
#[derive(Subcommand)]
pub enum UserCommand {
#[command(name = "user-create")]
Create {
#[arg(short, long)]
name: String,
#[arg(short, long)]
password: String,
},
#[command(name = "user-list")]
List,
#[command(name = "user-show")]
Show {
#[arg(short, long)]
name: String,
},
#[command(name = "user-delete")]
Delete {
#[arg(short, long)]
name: String,

View File

@@ -3,12 +3,14 @@ use std::path::Path;
#[derive(Subcommand)]
pub enum ArchiveCommand {
#[command(name = "archive-decompress")]
Decompress {
#[arg(short, long)]
file: String,
#[arg(short, long)]
output: String,
},
#[command(name = "archive-list")]
List {
#[arg(short, long)]
file: String,

View File

@@ -2,6 +2,7 @@ use clap::Subcommand;
#[derive(Subcommand)]
pub enum MountCommand {
#[command(name = "mount-attach")]
Attach {
#[arg(short, long)]
type_: String,
@@ -10,10 +11,12 @@ pub enum MountCommand {
#[arg(short, long)]
path: String,
},
#[command(name = "mount-detach")]
Detach {
#[arg(short, long)]
path: String,
},
#[command(name = "mount-list")]
List,
}

View File

@@ -2,6 +2,7 @@ use clap::Subcommand;
#[derive(Subcommand)]
pub enum SyncCommand {
#[command(name = "sync-start")]
Start {
#[arg(short, long)]
source: String,
@@ -10,6 +11,7 @@ pub enum SyncCommand {
#[arg(short, long, default_value = "mirror")]
mode: String,
},
#[command(name = "sync-status")]
Status,
}