-
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.
- Created `template` subcommand to manage reusable Git hook templates. - Implemented `create`, `copy`, `edit`, and `remove` subcommands for template management. - Added the ability to configure Git hook templates for multiple use cases. feat: add config subcommand - Created `config` subcommand to manage HkUp configuration settings. - Subcommands include `get` and `set` for managing configuration settings. - NOTE: This feature is currently hidden and will be available once configuration settings are finalized. chore: improve install script - Improved script to handle both installation and update operations when the version is lower than the release version. chore: update release-please GitHub action - Moved logic from `scripts/build` to `release-please` action. - Removed `scripts/build` to simplify release process. chore: use defaults for Go dependency checking - Removed settings for day, time, and timezone from Go dependency checking. - Dependabot now uses the default weekly time settings for Go dependencies. chore: fix pre-commit git hook - Removed adding all files after running the Go formatter, fixing the issue where unwanted files were being added to commits. refactor(cmd): simplify flag handling & init logic - Renamed flags for consistency: `Lang` to `LangFlg`, `GitDir` to `GitDirFlg`, `WorkTree` to `WorkTreeFlg`. - Consolidated command registration into `root.go`. - Simplified the `init()` function and centralized logic. refactor(logic): update flags and simplify hook commands - Simplified Add, Remove, and Init logic by centralizing directory checks. - Renamed flags: `Lang` to `LangFlg`, `GitDir` to `GitDirFlg`, `WorkTree` to `WorkTreeFlg`. - Improved readability and error handling in file operations. refactor(git): improve comments and simplify hook logic - Updated comments for clarity and consistency in the Git package. - Simplified `GetHook` and `GetLang` functions to improve readability. - Updated the `supportedLangs` map to explicitly include `sh` and `bash`. feat(util): add file ops, prompts, and config functions - Added utility functions for terminal prompts: `YesNoPrompt` and `UserInputPrompt`. - Expanded file handling functions: `CreateDirectory` and `CopyFile`. - Introduced functions to handle HkUp configuration paths: `GetConfigDirPath`, `GetConfigFilePath`, `GetTemplateDirPath`. - Added functions for TOML file manipulation: `GetTOMLValue`, `SetTOMLValue`. - Implemented `GetEditor` function to determine the default editor based on configuration, git, or environment variables.
- Loading branch information
Showing
39 changed files
with
1,319 additions
and
237 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
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
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,17 @@ | ||
package config | ||
|
||
import ( | ||
"github.com/iton0/hkup-cli/internal/logic/config" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var ( | ||
getCmd = &cobra.Command{ | ||
Use: "get <config-setting>", | ||
Short: "Get a HkUp config setting", | ||
Args: cobra.ExactArgs(1), | ||
RunE: config.Get, | ||
} | ||
) | ||
|
||
func init() {} |
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,9 @@ | ||
/* | ||
Package template initializes the config subcommand and its subcommands. | ||
This package is utilized in the root command of [github.com/iton0/hkup-cli/cmd] | ||
package. | ||
*/ | ||
package config | ||
|
||
// NOTE: This file is for documentation purposes and should be kept empty. |
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 config | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var ( | ||
// RootCmd is the config command that will be added to the root HkUp command. | ||
RootCmd = &cobra.Command{ | ||
Use: "config", | ||
Short: "HkUp configuration settings", | ||
Hidden: true, // TODO: remove after finalizing configuration settings | ||
} | ||
) | ||
|
||
func init() { | ||
RootCmd.AddCommand(getCmd) | ||
RootCmd.AddCommand(setCmd) | ||
} |
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,17 @@ | ||
package config | ||
|
||
import ( | ||
"github.com/iton0/hkup-cli/internal/logic/config" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var ( | ||
setCmd = &cobra.Command{ | ||
Use: "set <config-setting> <value>", | ||
Short: "Set a HkUp config setting", | ||
Args: cobra.ExactArgs(2), | ||
RunE: config.Set, | ||
} | ||
) | ||
|
||
func init() {} |
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 |
---|---|---|
|
@@ -18,6 +18,4 @@ var ( | |
} | ||
) | ||
|
||
func init() { | ||
rootCmd.AddCommand(docCmd) | ||
} | ||
func init() {} |
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 |
---|---|---|
|
@@ -16,6 +16,4 @@ var ( | |
} | ||
) | ||
|
||
func init() { | ||
rootCmd.AddCommand(listCmd) | ||
} | ||
func init() {} |
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,8 +1,6 @@ | ||
/* | ||
Package cmd initializes all commands (including root command) for the HkUp CLI. | ||
Additionally, the package holds all tests for commands. | ||
*/ | ||
package cmd | ||
|
||
// Note: This file should be kept empty. | ||
// NOTE: This file is for documentation purposes and should be kept empty. |
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 |
---|---|---|
|
@@ -18,6 +18,4 @@ var ( | |
} | ||
) | ||
|
||
func init() { | ||
rootCmd.AddCommand(removeCmd) | ||
} | ||
func init() {} |
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,23 +1,39 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/iton0/hkup-cli/cmd/config" | ||
"github.com/iton0/hkup-cli/cmd/template" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var ( | ||
// version holds the centralized version of HkUp. | ||
// It is updated to the latest release version at build time of the binaries. | ||
// | ||
// INFO: look at the .github/workflows/release-please.yml to view how version | ||
// is updated. | ||
version = "dev" | ||
|
||
rootCmd = &cobra.Command{ | ||
Use: "hkup", | ||
Short: "hkup CLI", | ||
Long: `hkup is a management tool for git hooks`, | ||
Args: cobra.MinimumNArgs(1), | ||
Version: "0.2.1", | ||
Version: version, | ||
} | ||
) | ||
|
||
func init() {} | ||
func init() { | ||
rootCmd.AddCommand(initCmd) | ||
rootCmd.AddCommand(addCmd) | ||
rootCmd.AddCommand(removeCmd) | ||
rootCmd.AddCommand(template.RootCmd) | ||
rootCmd.AddCommand(config.RootCmd) | ||
rootCmd.AddCommand(docCmd) | ||
rootCmd.AddCommand(listCmd) | ||
} | ||
|
||
// Execute serves as a wrapper for the Cobra API's Execute function, | ||
// allowing it to be called from the main package. | ||
// allowing it to be called from the [github.com/iton0/hkup-cli] package. | ||
func Execute() { | ||
rootCmd.Execute() | ||
} |
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,17 @@ | ||
package template | ||
|
||
import ( | ||
"github.com/iton0/hkup-cli/internal/logic/template" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var ( | ||
copyCmd = &cobra.Command{ | ||
Use: "copy <template-name>", | ||
Short: "Copy a git hook template", | ||
Args: cobra.ExactArgs(1), | ||
RunE: template.Copy, | ||
} | ||
) | ||
|
||
func init() {} |
Oops, something went wrong.