cli: 增加 --quiet 静默模式
Signed-off-by: Jia Chao <jiac13@chinaunicom.cn>
This commit is contained in:
parent
6020ca43ba
commit
1bf5868fce
31
src/cli.rs
31
src/cli.rs
|
@ -0,0 +1,31 @@
|
||||||
|
use clap::Parser;
|
||||||
|
|
||||||
|
/// cuweb-syncer 是一个用于从远程 web 服务器同步文件至本地的命令行工具。
|
||||||
|
#[derive(Clone, Debug, Parser)]
|
||||||
|
#[command(author, version, about, long_about = None)]
|
||||||
|
pub(crate) struct Cli {
|
||||||
|
/// 在终端输出当前的配置文件内容
|
||||||
|
#[arg(long, default_value_t = false)]
|
||||||
|
pub config: bool,
|
||||||
|
|
||||||
|
/// 是否开启 debug 模式,将打印更详尽的日志信息
|
||||||
|
#[arg(long, default_value_t = false)]
|
||||||
|
pub debug: bool,
|
||||||
|
|
||||||
|
/// 静默模式,如任务运行正常则无任何信息输出
|
||||||
|
#[arg(long, default_value_t = false)]
|
||||||
|
pub quiet: bool,
|
||||||
|
|
||||||
|
/// 可选项,需配合 `dest` 参数使用,只运行一次指定的同步任务,指定服务器地址
|
||||||
|
#[arg(short, long)]
|
||||||
|
pub from: Option<String>,
|
||||||
|
|
||||||
|
/// 可选项,需配合 `from` 参数使用,只运行一次指定的同步任务,指定同步的本地路径
|
||||||
|
#[arg(short, long)]
|
||||||
|
pub dest: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 从命令行环境变量读取并转换为 `Cli`
|
||||||
|
pub(crate) fn parse() -> Cli {
|
||||||
|
Cli::parse()
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user