初步设定命令行参数样式
Signed-off-by: Jia Chao <jiac13@chinaunicom.cn>
This commit is contained in:
parent
462aa4a69f
commit
976d5016f0
|
@ -4,3 +4,4 @@ version = "0.1.0"
|
|||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.0", features = ["derive"] }
|
||||
|
|
48
src/cli.rs
Normal file
48
src/cli.rs
Normal file
|
@ -0,0 +1,48 @@
|
|||
use clap::{Parser, command};
|
||||
|
||||
/// CULinux Vulnerability Analyze Tool (简称 CULinux-VAT) 是一个用于分析是一个用于分析和检测 Linux
|
||||
/// 系统漏洞的工具。该工具旨在帮助系统管理员和安全专业人员识别和修复潜在的安全漏洞,以确保 CULinux
|
||||
/// 系统的安全性和稳定性
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(author, version, about, long_about = None)]
|
||||
pub struct Cli {
|
||||
/// 显示当前系统的整体安全情况
|
||||
#[arg(short, long, default_value_t = true)]
|
||||
pub summary: bool,
|
||||
|
||||
/// 列出所有已发布但未修复的安全公告
|
||||
#[arg(short, long, default_value_t = false)]
|
||||
pub list: bool,
|
||||
|
||||
/// 列出并查看已修复但尚未更新的 cve 漏洞信息
|
||||
#[arg(long, default_value_t = false)]
|
||||
pub cves: bool,
|
||||
|
||||
/// 列出并查看已修复但尚未更新的 sa 安全公告信息
|
||||
#[arg(long, default_value_t = false)]
|
||||
pub sas: bool,
|
||||
|
||||
/// 查看对应 sa / cve 的详情信息
|
||||
#[arg(long, default_value_t = false)]
|
||||
pub info: bool,
|
||||
|
||||
/// 使用 --cves 或 --sas 时, 指定要查看的 id 列表
|
||||
#[arg(action = clap::ArgAction::Append)]
|
||||
pub sources: Vec<String>,
|
||||
|
||||
/// 设置过滤级别,由高到低为:[Critical, Important, Moderate, Low]
|
||||
#[arg(long, default_value_t = String::from("Low"))]
|
||||
pub severity: String,
|
||||
|
||||
/// 生成漏洞扫描报告
|
||||
#[arg(long, default_value_t = false)]
|
||||
pub report: bool,
|
||||
|
||||
/// 使用 dnf 后端进行安全扫描
|
||||
#[arg(long, default_value_t = false)]
|
||||
pub dnf: bool,
|
||||
}
|
||||
|
||||
pub fn parse() -> Cli {
|
||||
Cli::parse()
|
||||
}
|
13
src/lib.rs
Normal file
13
src/lib.rs
Normal file
|
@ -0,0 +1,13 @@
|
|||
pub mod cli;
|
||||
|
||||
/// 定义 crate::Error
|
||||
/// 大部分函数返回的错误
|
||||
pub type Error = Box<dyn std::error::Error + Send + Sync>;
|
||||
|
||||
/// 定义 crate::Result
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
pub fn cumain() -> Result<()> {
|
||||
let _cli = cli::parse();
|
||||
Ok(())
|
||||
}
|
|
@ -1,3 +1,3 @@
|
|||
fn main() {
|
||||
println!("Hello, world!");
|
||||
fn main() -> cuvat_rs::Result<()> {
|
||||
cuvat_rs::cumain()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user