-
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
Showing
15 changed files
with
108 additions
and
57 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
File renamed without changes.
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 |
---|---|---|
@@ -1,26 +1,18 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/kostikovk/gohooks/helpers" | ||
"github.com/kostikovk/hooky/lib" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var listCmd = &cobra.Command{ | ||
Use: "list", | ||
Short: "List all available hooks", | ||
Long: `List all available hooks.`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
fmt.Println("List all available hooks:") | ||
|
||
// todo: need to implement this function | ||
for i, hook := range helpers.GitHooks { | ||
fmt.Printf("%d. %s\n", i+1, hook) | ||
} | ||
}, | ||
Run: lib.RunList, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(listCmd) | ||
listCmd.Flags().Bool("installed", false, "Show only installed hooks") | ||
} |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module github.com/kostikovk/gohooks | ||
module github.com/kostikovk/hooky | ||
|
||
go 1.22.4 | ||
|
||
|
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,45 @@ | ||
package lib | ||
|
||
import ( | ||
"github.com/kostikovk/hooky/helpers" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// Whant to implement: | ||
// 1. Show all available hooks | ||
// 2. Show all hooks that are installed | ||
// 3. Show all hooks that are not installed | ||
// 4. Ask a user about installing a hook | ||
|
||
func RunList(cmd *cobra.Command, args []string) { | ||
installed, _ := cmd.Flags().GetBool("installed") | ||
|
||
if installed { | ||
showListOfInstalledHooks(cmd) | ||
} else { | ||
showListOfAvailableHooks(cmd) | ||
} | ||
} | ||
|
||
func showListOfAvailableHooks(cmd *cobra.Command) { | ||
cmd.Println("Git Hooks:") | ||
|
||
for i, hook := range helpers.GitHooks { | ||
cmd.Printf("%d. %s\n", i, hook) | ||
} | ||
} | ||
|
||
func showListOfInstalledHooks(cmd *cobra.Command) { | ||
cmd.Println("Installed Git Hooks:") | ||
|
||
var installedHooks []string | ||
var err error | ||
installedHooks, err = helpers.ListOfInstalledGitHooks() | ||
if err != nil { | ||
cmd.PrintErr("Error listing installed hooks.") | ||
} | ||
|
||
for i, hook := range installedHooks { | ||
cmd.Printf("%d. %s\n", i, 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
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,7 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/kostikovk/gohooks/cmd" | ||
"github.com/kostikovk/hooky/cmd" | ||
) | ||
|
||
func main() { | ||
|