-
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
73 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var hookCmd = &cobra.Command{ | ||
Use: "hook", | ||
Short: "Run git hooks", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
GroupID: groups[group_low_level_helper].ID, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(hookCmd).Standalone() | ||
|
||
rootCmd.AddCommand(hookCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/carapace-sh/carapace-bin/pkg/actions/tools/git" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var hook_runCmd = &cobra.Command{ | ||
Use: "run [--ignore-missing] [--to-stdin=<path>] <hook-name> [-- <hook-args>]", | ||
Short: "Run git hooks", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(hook_runCmd).Standalone() | ||
|
||
hook_runCmd.Flags().Bool("ignore-missing", false, "ignore any missing hook by quietly returning zero") | ||
hook_runCmd.Flags().String("to-stdin", "", "specify a file which will be streamed into the hook’s stdin") | ||
hookCmd.AddCommand(hook_runCmd) | ||
|
||
carapace.Gen(hook_runCmd).FlagCompletion(carapace.ActionMap{ | ||
"to-stdin": carapace.ActionFiles(), | ||
}) | ||
|
||
carapace.Gen(hook_runCmd).PositionalCompletion( | ||
git.ActionHooks(), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package git | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/carapace-sh/carapace/pkg/traverse" | ||
) | ||
|
||
// ActionHooks completes hooks | ||
// | ||
// pre-commit.sample | ||
// pre-merge-commit.sample | ||
func ActionHooks() carapace.Action { | ||
return carapace.ActionExecutables("hooks"). | ||
ChdirF(traverse.GitDir). | ||
Tag("hooks") | ||
} |