107 lines
2.1 KiB
Rust
107 lines
2.1 KiB
Rust
// NAC Developer Toolbox v2.0 CLI扩展
|
||
use clap::{Parser, Subcommand, ValueEnum};
|
||
use std::path::PathBuf;
|
||
|
||
#[derive(Parser, Clone)]
|
||
#[command(name = "nac")]
|
||
#[command(version = "2.0.0")]
|
||
#[command(about = "NAC Developer Toolbox v2.0 - 完美中心化框架下的去中心化开发工具")]
|
||
pub struct CliV2 {
|
||
#[command(subcommand)]
|
||
pub command: CommandsV2,
|
||
}
|
||
|
||
#[derive(Subcommand, Clone)]
|
||
pub enum CommandsV2 {
|
||
/// 创建新项目(宪法/合约/节点)
|
||
New {
|
||
name: String,
|
||
#[arg(long, value_enum, default_value = "contract")]
|
||
r#type: ProjectType,
|
||
},
|
||
|
||
/// 当前目录初始化为NAC项目
|
||
Init {
|
||
#[arg(long, value_enum, default_value = "contract")]
|
||
r#type: ProjectType,
|
||
},
|
||
|
||
/// 编译当前项目(自动识别类型)
|
||
Build {
|
||
#[arg(long)]
|
||
release: bool,
|
||
},
|
||
|
||
/// 宪法合规性检查(不生成字节码)
|
||
Check,
|
||
|
||
/// 运行测试(含宪法沙箱)
|
||
Test {
|
||
#[arg(long)]
|
||
contract: bool,
|
||
},
|
||
|
||
/// 宪法沙箱 - 模拟宪法变更影响
|
||
Sandbox {
|
||
#[arg(long)]
|
||
duration: String,
|
||
#[arg(long)]
|
||
constitution: PathBuf,
|
||
},
|
||
|
||
/// 工具链管理
|
||
Tool {
|
||
#[command(subcommand)]
|
||
action: ToolAction,
|
||
},
|
||
|
||
/// 启动LSP服务器(IDE集成)
|
||
Lsp {
|
||
#[arg(long)]
|
||
stdio: bool,
|
||
},
|
||
|
||
/// 生成shell补全脚本
|
||
Completions {
|
||
shell: String,
|
||
},
|
||
|
||
/// 打开本地文档
|
||
Docs,
|
||
|
||
/// 显示详细版本信息
|
||
Version,
|
||
}
|
||
|
||
#[derive(ValueEnum, Clone)]
|
||
pub enum ProjectType {
|
||
/// 宪法条款项目
|
||
Constitution,
|
||
/// 智能合约项目
|
||
Contract,
|
||
/// 节点插件项目
|
||
NodePlugin,
|
||
}
|
||
|
||
#[derive(Subcommand, Clone)]
|
||
pub enum ToolAction {
|
||
/// 安装指定版本工具链
|
||
Install {
|
||
version: String,
|
||
},
|
||
|
||
/// 切换默认版本
|
||
Use {
|
||
version: String,
|
||
},
|
||
|
||
/// 列出已安装版本
|
||
List,
|
||
|
||
/// 同步项目锁定版本
|
||
Sync,
|
||
|
||
/// 验证工具箱完整性
|
||
Verify,
|
||
}
|