更新命令行参数,更新 README

Signed-off-by: Jia Chao <jiac13@chinaunicom.cn>
This commit is contained in:
Jia Chao 2024-06-27 17:05:27 +08:00
parent e29b653964
commit a6cdd8e39b
2 changed files with 49 additions and 1 deletions

View File

@ -1 +1,17 @@
这个应用于 CULinux VAT 系统中,将 openEuler 的 cvrf 格式的安全公告转换为 cusa。 这个应用于 CULinux VAT 系统中,将 openEuler 的 cvrf 格式的安全公告转换为 cusa。
```
$ cvrf2cusa -h
cvrf2cusa 是一个用于将 CVRFCommon Vulnerability Reporting Framework格式的安全报告转换为 CUSACULinux Security Advisory的工具其输入格式为 Xml ,输出格式则为 Json。
Usage: cvrf2cusa <COMMAND>
Commands:
convert CVRF 转换输出子命令
db 创建并生成新的 CUSA 数据文件
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
```

View File

@ -1,4 +1,4 @@
use clap::Parser; use clap::{Parser, Subcommand};
// 构建命令行工具的结构体 // 构建命令行工具的结构体
/// cvrf2cusa 是一个用于将 CVRFCommon Vulnerability Reporting Framework格式的安全报告转换为 /// cvrf2cusa 是一个用于将 CVRFCommon Vulnerability Reporting Framework格式的安全报告转换为
@ -6,6 +6,22 @@ use clap::Parser;
#[derive(Clone, Debug, Parser)] #[derive(Clone, Debug, Parser)]
#[command(author, version, about, long_about = None)] #[command(author, version, about, long_about = None)]
pub struct Cli { pub struct Cli {
#[clap(subcommand)]
pub subcommand: CliSub,
}
#[derive(Subcommand, Debug, Clone)]
pub enum CliSub {
/// CVRF 转换输出子命令
Convert(ConvertCli),
/// 创建并生成新的 CUSA 数据文件
Db(SaDbCli),
}
#[derive(Clone, Debug, Parser)]
#[command(author, version, about, long_about = None)]
pub struct ConvertCli {
/// 输入的文件,应为 cvrf 格式的 xml /// 输入的文件,应为 cvrf 格式的 xml
#[arg(short, long)] #[arg(short, long)]
pub input: String, pub input: String,
@ -20,6 +36,22 @@ pub struct Cli {
pub print: bool, pub print: bool,
} }
#[derive(Clone, Debug, Parser)]
#[command(author, version, about, long_about = None)]
pub struct SaDbCli {
/// 指定一个目录,递归读取其内部的 cvrf 格式的 xml 文件,并最终生成新的 SADB
#[arg(short, long)]
pub from: String,
/// 输出的 sa db 文件,默认为当前路径下的 sainfos
#[arg(long, default_value_t = String::from("sainfos"))]
pub sa: String,
/// 输出的 cve db 文件,默认为当前路径下的 cves
#[arg(long, default_value_t = String::from("cves"))]
pub cve: String,
}
// 从命令行环境变量读取并转换为 `Cli` // 从命令行环境变量读取并转换为 `Cli`
pub fn parse() -> Cli { pub fn parse() -> Cli {
Cli::parse() Cli::parse()