-
Notifications
You must be signed in to change notification settings - Fork 0
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
Kostiantyn Kostikov
committed
Dec 1, 2024
1 parent
70efd97
commit 1d01687
Showing
8 changed files
with
96 additions
and
11 deletions.
There are no files selected for viewing
Empty file.
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 |
---|---|---|
@@ -1,7 +1,34 @@ | ||
# Hooky CLI [WIP] | ||
|
||
Hooky CLI is a command-line tool for managing Git hooks in Go projects. It helps developers easily set up, configure, and run Git hooks, such as pre-commit hooks, in a Go-centric environment. | ||
**Hooky CLI** is a command-line tool for managing Git hooks in Go projects. Designed with simplicity and efficiency in mind, Hooky makes it easy to set up, configure, and run Git hooks such as pre-commit, pre-push, and more. Whether you’re enforcing coding standards, running tests, or automating tasks, Hooky streamlines the process in a Go-centric development workflow. | ||
|
||
## Features | ||
- **Manage Git Hooks**: Create, configure, and manage Git hooks like pre-commit, commit-msg, and more. | ||
- **Cross-Platform**: Works on Linux, macOS, and Windows. | ||
- **Easy Hook Management**: Install and configure Git hooks effortlessly. | ||
- **Go-Friendly**: Optimized for Go projects and workflows. | ||
- **Customizable Hooks**: Define and execute your custom Git hooks. | ||
- **Seamless Integration**: Works out of the box with Git repositories. | ||
|
||
## Installation | ||
To install Hooky CLI, run the following command: | ||
|
||
```bash | ||
go install github.com/kostikovk/hooky@latest | ||
``` | ||
**Note:** Replace @latest with a specific version if you want to install a particular release. | ||
|
||
## Usage | ||
To get started with Hooky CLI, run the following command: | ||
|
||
```bash | ||
hooky init | ||
``` | ||
This command initializes Hooky in your Git repository and creates a `.hooky` directory with default hooks. | ||
|
||
## Install specific hook | ||
To install a specific hook, run the following command: | ||
|
||
```bash | ||
hooky install pre-commit | ||
``` | ||
This command installs the `pre-commit` hook in your Git repository. | ||
If it's already installed, it will overwrite the existing hook. |
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,18 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/kostikovk/hooky/lib" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var installCmd = &cobra.Command{ | ||
Use: "install [hook]", | ||
Short: "Install a specific Git hook", | ||
Long: `Install a specific Git hook, such as pre-commit or pre-push, and set up the necessary scripts to execute the hook logic.`, | ||
Args: cobra.ExactArgs(1), | ||
Run: lib.RunInstall, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(installCmd) | ||
} |
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
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,26 @@ | ||
package lib | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/kostikovk/hooky/helpers" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func RunInstall(cmd *cobra.Command, args []string) { | ||
installHook(cmd, args[0]) | ||
} | ||
|
||
func installHook(cmd *cobra.Command, hook string) { | ||
fmt.Printf("Installing %s hook...\n", hook) | ||
|
||
err := helpers.CreateGitHook(hook, "# go test ./...") | ||
if err != nil { | ||
cmd.PrintErr(err) | ||
|
||
os.Exit(1) | ||
} | ||
|
||
cmd.Printf("Hook %s installed.", hook) | ||
} |
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