更新命令行参数,更新 README
Signed-off-by: Jia Chao <jiac13@chinaunicom.cn>
This commit is contained in:
parent
e29b653964
commit
a6cdd8e39b
16
README.md
16
README.md
@ -1 +1,17 @@
|
||||
这个应用于 CULinux VAT 系统中,将 openEuler 的 cvrf 格式的安全公告转换为 cusa。
|
||||
|
||||
```
|
||||
$ cvrf2cusa -h
|
||||
cvrf2cusa 是一个用于将 CVRF(Common Vulnerability Reporting Framework)格式的安全报告转换为 CUSA(CULinux 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
|
||||
```
|
||||
|
34
src/cli.rs
34
src/cli.rs
@ -1,4 +1,4 @@
|
||||
use clap::Parser;
|
||||
use clap::{Parser, Subcommand};
|
||||
|
||||
// 构建命令行工具的结构体
|
||||
/// cvrf2cusa 是一个用于将 CVRF(Common Vulnerability Reporting Framework)格式的安全报告转换为
|
||||
@ -6,6 +6,22 @@ use clap::Parser;
|
||||
#[derive(Clone, Debug, Parser)]
|
||||
#[command(author, version, about, long_about = None)]
|
||||
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
|
||||
#[arg(short, long)]
|
||||
pub input: String,
|
||||
@ -20,6 +36,22 @@ pub struct Cli {
|
||||
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`
|
||||
pub fn parse() -> Cli {
|
||||
Cli::parse()
|
||||
|
Loading…
x
Reference in New Issue
Block a user