From 76da22e66aaccda4a428e41e233ef7f3732463fd Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 18 Nov 2019 15:22:51 +0300 Subject: Don't create a separate bin for format hook --- xtask/src/main.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'xtask/src/main.rs') 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; use std::{env, path::PathBuf}; use xtask::{ codegen::{self, Mode}, - install_format_hook, run, run_clippy, run_fuzzer, run_rustfmt, run_with_output, Cmd, Result, + install_pre_commit_hook, reformat_staged_files, run, run_clippy, run_fuzzer, run_rustfmt, + run_with_output, Cmd, Result, }; // Latest stable, feel free to send a PR if this lags behind. @@ -36,6 +37,10 @@ struct ServerOpt { } fn main() -> Result<()> { + if std::env::args().next().map(|it| it.contains("pre-commit")) == Some(true) { + return reformat_staged_files(); + } + let subcommand = match std::env::args_os().nth(1) { None => { eprintln!("{}", help::GLOBAL_HELP); @@ -81,12 +86,12 @@ fn main() -> Result<()> { } run_rustfmt(Mode::Overwrite)? } - "format-hook" => { + "install-pre-commit-hook" => { if matches.contains(["-h", "--help"]) { help::print_no_param_subcommand_help(&subcommand); return Ok(()); } - install_format_hook()? + install_pre_commit_hook()? } "lint" => { if matches.contains(["-h", "--help"]) { -- cgit v1.2.3