diff options
Diffstat (limited to 'xtask/src/main.rs')
-rw-r--r-- | xtask/src/main.rs | 11 |
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; | |||
16 | use std::{env, path::PathBuf}; | 16 | use std::{env, path::PathBuf}; |
17 | use xtask::{ | 17 | use 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 | ||
38 | fn main() -> Result<()> { | 39 | fn 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"]) { |