From cb1b8187fa70f2afbed11b91c71e45b5f4ab0bc8 Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Sun, 24 Jan 2021 22:31:11 +0800 Subject: [PATCH] feat: update dependency version, add clap run_with --- Cargo.toml | 10 +++++----- src/util_clap.rs | 6 +++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d62ab5d..648200b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rust_util" -version = "0.6.27" +version = "0.6.28" authors = ["Hatter Jiang "] edition = "2018" description = "Hatter's Rust Util" @@ -13,10 +13,10 @@ default = [] #["serde", "serde_json"] use_clap = ["clap"] [dependencies] -libc = "0.2.65" -term = "0.5.2" -term_size = "0.3.1" -lazy_static = "1.3.0" +libc = "0.2.82" +term = "0.7.0" +term_size = "0.3.2" +lazy_static = "1.4.0" clap = { version = "2.0", optional = true } # serde = { version = "1.0", features = ["derive"], optional = true } # serde_json = { version = "1.0", optional = true } diff --git a/src/util_clap.rs b/src/util_clap.rs index d986181..4674135 100644 --- a/src/util_clap.rs +++ b/src/util_clap.rs @@ -59,9 +59,13 @@ impl CommandExecutor { } pub fn run(&self) -> XResult<()> { - let mut app = App::new(env!("CARGO_PKG_NAME")) + let app = App::new(env!("CARGO_PKG_NAME")) .version(env!("CARGO_PKG_VERSION")) .about(env!("CARGO_PKG_DESCRIPTION")); + self.run_with(app) + } + + pub fn run_with<'a>(&self, mut app: App<'a, 'a>) -> XResult<()> { if let Some(default_cmd) = &self.default_cmd { app = default_cmd.process_command(app); }