mirror of
https://github.com/jht5945/rust_util.git
synced 2026-01-13 15:50:05 +08:00
Compare commits
2 Commits
50159a0ca8
...
4b39ac48fd
| Author | SHA1 | Date | |
|---|---|---|---|
| 4b39ac48fd | |||
| cb1b8187fa |
10
Cargo.toml
10
Cargo.toml
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "rust_util"
|
||||
version = "0.6.27"
|
||||
version = "0.6.29"
|
||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
||||
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 }
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,15 @@ pub fn git_status_change(working_dir: Option<&str>) -> XResult<GitStatusChange>
|
||||
parse_git_status_change(&git_status)
|
||||
}
|
||||
|
||||
pub fn git_rev_parse_head(working_dir: Option<&str>) -> XResult<String> {
|
||||
let mut cmd = new_git_command(working_dir);
|
||||
cmd.args(vec!["rev-parse", "HEAD"]);
|
||||
util_msg::print_info(&format!("Exec: {:?}", cmd));
|
||||
let output = cmd.output()?;
|
||||
let rev_parse_head = String::from_utf8(output.stdout)?;
|
||||
Ok(rev_parse_head.trim().to_string())
|
||||
}
|
||||
|
||||
pub fn git_fetch_dry_run(working_dir: Option<&str>) -> XResult<bool> {
|
||||
let mut cmd = new_git_command(working_dir);
|
||||
cmd.args(vec!["fetch", "--dry-run"]);
|
||||
|
||||
Reference in New Issue
Block a user