mirror of
https://github.com/jht5945/rust_util.git
synced 2025-12-27 15:40:03 +08:00
feat: update dependency version, add clap run_with
This commit is contained in:
10
Cargo.toml
10
Cargo.toml
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "rust_util"
|
name = "rust_util"
|
||||||
version = "0.6.27"
|
version = "0.6.28"
|
||||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
description = "Hatter's Rust Util"
|
description = "Hatter's Rust Util"
|
||||||
@@ -13,10 +13,10 @@ default = [] #["serde", "serde_json"]
|
|||||||
use_clap = ["clap"]
|
use_clap = ["clap"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
libc = "0.2.65"
|
libc = "0.2.82"
|
||||||
term = "0.5.2"
|
term = "0.7.0"
|
||||||
term_size = "0.3.1"
|
term_size = "0.3.2"
|
||||||
lazy_static = "1.3.0"
|
lazy_static = "1.4.0"
|
||||||
clap = { version = "2.0", optional = true }
|
clap = { version = "2.0", optional = true }
|
||||||
# serde = { version = "1.0", features = ["derive"], optional = true }
|
# serde = { version = "1.0", features = ["derive"], optional = true }
|
||||||
# serde_json = { version = "1.0", optional = true }
|
# serde_json = { version = "1.0", optional = true }
|
||||||
|
|||||||
@@ -59,9 +59,13 @@ impl CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn run(&self) -> XResult<()> {
|
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"))
|
.version(env!("CARGO_PKG_VERSION"))
|
||||||
.about(env!("CARGO_PKG_DESCRIPTION"));
|
.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 {
|
if let Some(default_cmd) = &self.default_cmd {
|
||||||
app = default_cmd.process_command(app);
|
app = default_cmd.process_command(app);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user