feat: add usage for commit-msg
This commit is contained in:
@@ -9,6 +9,10 @@ fn main() {
|
|||||||
exit_with_error_message("Commit message is EMPTY!");
|
exit_with_error_message("Commit message is EMPTY!");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if arg1 == "usage" || arg1 == "USAGE" {
|
||||||
|
print_usage(); return;
|
||||||
|
}
|
||||||
|
|
||||||
let is_install = arg1 == "install" || arg1 == "INSTALL";
|
let is_install = arg1 == "install" || arg1 == "INSTALL";
|
||||||
let is_force_install = arg1 == "forceinstall" || arg1 == "FORCEINSTALL"
|
let is_force_install = arg1 == "forceinstall" || arg1 == "FORCEINSTALL"
|
||||||
|| arg1 == "force-install" || arg1 == "FORCE-INSTALL"
|
|| arg1 == "force-install" || arg1 == "FORCE-INSTALL"
|
||||||
@@ -28,9 +32,21 @@ fn main() {
|
|||||||
if is_commit_message_matches {
|
if is_commit_message_matches {
|
||||||
print_ok("Commit message rule matches");
|
print_ok("Commit message rule matches");
|
||||||
} else {
|
} else {
|
||||||
print_info(&format!(r#"Please follow the commit spec:
|
print_usage();
|
||||||
Format: <type>(<scope>): <subject>
|
exit_with_error_message("Commit message rule is NOT matched");
|
||||||
<scope> is optional
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const RED: &str = "\x1B[91m";
|
||||||
|
const GREEN: &str = "\x1B[92m";
|
||||||
|
const BOLD: &str = "\x1B[1m";
|
||||||
|
const UNDER: &str = "\x1B[4m";
|
||||||
|
const END: &str = "\x1B[0m";
|
||||||
|
|
||||||
|
fn print_usage() {
|
||||||
|
print_info(&format!(r#"Please follow the commit spec:
|
||||||
|
Format: {}<type>{}(<scope>){}: <subject>{}
|
||||||
|
<scope> is optional
|
||||||
|
|
||||||
feat: add hat wobble
|
feat: add hat wobble
|
||||||
^--^ ^------------^
|
^--^ ^------------^
|
||||||
@@ -49,17 +65,9 @@ chore : updating grunt tasks etc; no production code change
|
|||||||
|
|
||||||
Reference: {}https://gist.github.com/joshbuchea/6f47e86d2510bce28f8e7f42ae84c716{}
|
Reference: {}https://gist.github.com/joshbuchea/6f47e86d2510bce28f8e7f42ae84c716{}
|
||||||
or mirror: {}https://hatter.ink/wiki/view_raw.action?__access_token=PUBLIC&id=42{}
|
or mirror: {}https://hatter.ink/wiki/view_raw.action?__access_token=PUBLIC&id=42{}
|
||||||
"#, UNDER, END, UNDER, END));
|
"#, BOLD, END, BOLD, END, UNDER, END, UNDER, END));
|
||||||
exit_with_error_message("Commit message rule is NOT matched");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const RED: &str = "\x1B[91m";
|
|
||||||
const GREEN: &str = "\x1B[92m";
|
|
||||||
const BOLD: &str = "\x1B[1m";
|
|
||||||
const UNDER: &str = "\x1B[4m";
|
|
||||||
const END: &str = "\x1B[0m";
|
|
||||||
|
|
||||||
fn install_commit_msg(force: bool) {
|
fn install_commit_msg(force: bool) {
|
||||||
let home_path = PathBuf::from(env::var("HOME").unwrap_or_else(|e| {
|
let home_path = PathBuf::from(env::var("HOME").unwrap_or_else(|e| {
|
||||||
exit_with_error_message(&format!("Get env HOME failed: {}!", e));
|
exit_with_error_message(&format!("Get env HOME failed: {}!", e));
|
||||||
|
|||||||
Reference in New Issue
Block a user