@@ -468,7 +468,7 @@ pub(crate) struct RunExtraArgs {
468468
469469#[ allow( clippy:: struct_excessive_bools) ]
470470#[ derive( Debug , Clone , Default , Args ) ]
471- pub ( crate ) struct RunArgs {
471+ pub ( crate ) struct RunOptions {
472472 /// Include the specified hooks or projects.
473473 ///
474474 /// Supports flexible selector syntax:
@@ -546,15 +546,6 @@ pub(crate) struct RunArgs {
546546 #[ arg( long, conflicts_with_all = [ "all_files" , "files" , "directory" , "from_ref" , "to_ref" ] ) ]
547547 pub ( crate ) last_commit : bool ,
548548
549- /// The stage during which the hook is fired.
550- ///
551- /// When specified, only hooks configured for that stage (for example `manual`,
552- /// `pre-commit`, or `pre-push`) will run.
553- /// Defaults to `pre-commit` if not specified.
554- /// For hooks specified directly in the command line, fallback to `manual` stage if no hooks found for `pre-commit` stage.
555- #[ arg( long, value_enum, alias = "hook-stage" ) ]
556- pub ( crate ) stage : Option < Stage > ,
557-
558549 /// When hooks fail, run `git diff` directly afterward.
559550 #[ arg( long) ]
560551 pub ( crate ) show_diff_on_failure : bool ,
@@ -575,6 +566,37 @@ pub(crate) struct RunArgs {
575566 pub ( crate ) extra : RunExtraArgs ,
576567}
577568
569+ #[ derive( Debug , Clone , Default , Args ) ]
570+ pub ( crate ) struct RunArgs {
571+ #[ command( flatten) ]
572+ pub ( crate ) options : RunOptions ,
573+
574+ /// The stage during which the hook is fired.
575+ ///
576+ /// When specified, only hooks configured for that stage (for example `manual`,
577+ /// `pre-commit`, or `pre-push`) will run.
578+ /// When not specified and no group filter is active, this command starts with
579+ /// hooks eligible for `pre-commit`. If no hook is selected and the command
580+ /// named hook IDs, those same IDs are matched again against hooks configured
581+ /// for `manual`. With `--group` or `--no-group`, omitting the stage lets
582+ /// hooks from any configured stage match, using the default file input mode;
583+ /// hooks that only run at `commit-msg` or `prepare-commit-msg` are ignored.
584+ #[ arg( long, value_enum, alias = "hook-stage" ) ]
585+ pub ( crate ) stage : Option < Stage > ,
586+
587+ /// Run hooks belonging to the specified group.
588+ ///
589+ /// Can be specified multiple times.
590+ #[ arg( long = "group" , value_name = "GROUP" ) ]
591+ pub ( crate ) groups : Vec < String > ,
592+
593+ /// Do not run hooks belonging to the specified group.
594+ ///
595+ /// Can be specified multiple times. Exclusion wins over inclusion.
596+ #[ arg( long = "no-group" , value_name = "GROUP" ) ]
597+ pub ( crate ) no_groups : Vec < String > ,
598+ }
599+
578600#[ derive( Debug , Clone , Default , Args ) ]
579601pub ( crate ) struct TryRepoArgs {
580602 /// Repository to source hooks from.
@@ -585,7 +607,17 @@ pub(crate) struct TryRepoArgs {
585607 pub ( crate ) rev : Option < String > ,
586608
587609 #[ command( flatten) ]
588- pub ( crate ) run_args : RunArgs ,
610+ pub ( crate ) run_args : RunOptions ,
611+
612+ /// The stage during which the hook is fired.
613+ ///
614+ /// When specified, only hooks configured for that stage (for example `manual`,
615+ /// `pre-commit`, or `pre-push`) will run.
616+ /// When not specified, this command starts with hooks eligible for
617+ /// `pre-commit`. If no hook is selected and the command named hook IDs,
618+ /// those same IDs are matched again against hooks configured for `manual`.
619+ #[ arg( long, value_enum, alias = "hook-stage" ) ]
620+ pub ( crate ) stage : Option < Stage > ,
589621}
590622
591623#[ derive( Debug , Clone , Copy , clap:: ValueEnum , Default , Serialize , Deserialize ) ]
0 commit comments