aboutsummaryrefslogtreecommitdiff
path: root/xtask/src/main.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-11-18 12:22:51 +0000
committerAleksey Kladov <[email protected]>2019-11-18 12:27:04 +0000
commit76da22e66aaccda4a428e41e233ef7f3732463fd (patch)
tree4448743e0fff2822c3f6bde607e4a97374441be3 /xtask/src/main.rs
parentb79d6789236bb53c5818949cc2960b5c4991cbeb (diff)
Don't create a separate bin for format hook
Diffstat (limited to 'xtask/src/main.rs')
-rw-r--r--xtask/src/main.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/xtask/src/main.rs b/xtask/src/main.rs
index f14e6c8ae..663e28103 100644
--- a/xtask/src/main.rs
+++ b/xtask/src/main.rs
@@ -16,7 +16,8 @@ use pico_args::Arguments;
16use std::{env, path::PathBuf}; 16use std::{env, path::PathBuf};
17use xtask::{ 17use xtask::{
18 codegen::{self, Mode}, 18 codegen::{self, Mode},
19 install_format_hook, run, run_clippy, run_fuzzer, run_rustfmt, run_with_output, Cmd, Result, 19 install_pre_commit_hook, reformat_staged_files, run, run_clippy, run_fuzzer, run_rustfmt,
20 run_with_output, Cmd, Result,
20}; 21};
21 22
22// Latest stable, feel free to send a PR if this lags behind. 23// Latest stable, feel free to send a PR if this lags behind.
@@ -36,6 +37,10 @@ struct ServerOpt {
36} 37}
37 38
38fn main() -> Result<()> { 39fn main() -> Result<()> {
40 if std::env::args().next().map(|it| it.contains("pre-commit")) == Some(true) {
41 return reformat_staged_files();
42 }
43
39 let subcommand = match std::env::args_os().nth(1) { 44 let subcommand = match std::env::args_os().nth(1) {
40 None => { 45 None => {
41 eprintln!("{}", help::GLOBAL_HELP); 46 eprintln!("{}", help::GLOBAL_HELP);
@@ -81,12 +86,12 @@ fn main() -> Result<()> {
81 } 86 }
82 run_rustfmt(Mode::Overwrite)? 87 run_rustfmt(Mode::Overwrite)?
83 } 88 }
84 "format-hook" => { 89 "install-pre-commit-hook" => {
85 if matches.contains(["-h", "--help"]) { 90 if matches.contains(["-h", "--help"]) {
86 help::print_no_param_subcommand_help(&subcommand); 91 help::print_no_param_subcommand_help(&subcommand);
87 return Ok(()); 92 return Ok(());
88 } 93 }
89 install_format_hook()? 94 install_pre_commit_hook()?
90 } 95 }
91 "lint" => { 96 "lint" => {
92 if matches.contains(["-h", "--help"]) { 97 if matches.contains(["-h", "--help"]) {