-
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.
- improved script to either install or update when version is lower than release version. chore: update release-please github action - deleted the scripts/build script - moved the logic from the scripts/build script to the release-please action chore: use defaults for go dependency checking - removed settings for day, time, and timezone from dependency checking for go mod The dependabot now uses the default weekly time settings. chore: fix pre-commit git hook - removed adding all files after running go formatter This fixes issue of unwanted files/directories added to the commit. feat: add template subcommand - created template subcommand for use with git hook templates (reusable git hooks) - created subcommands for template to create, copy, edit, and remove templates. feat: add config subcommand - created HkUp configuration settings - created subcommands for config to get and set configuration settings NOTE: this feature is hidden and will be available when configuration settings are finalized. refactor(cmd): simplify flag handling & init logic - Rename flags for consistency: `Lang` to `LangFlg`, `GitDir` to `GitDirFlg`, and `WorkTree` to `WorkTreeFlg`. - Consolidate command registration in `root.go` by removing redundant `rootCmd.AddCommand` calls from individual command files (add.go, remove.go, list.go, doc.go). - Simplify `init()` functions in command files to centralize logic. - Update root command version handling to dynamically use `version` variable. - Clarify documentation comment in `main.go`. refactor(logic): update flags and simplify hook commands - Rename flags: `Lang` to `LangFlg`, `GitDir` to `GitDirFlg`, `WorkTree` to `WorkTreeFlg` for consistency. - Simplify the Add, Remove, and Init logic by centralizing directory checks and reducing redundant code. - Update file handling to improve readability and error handling. - Adjust comments for better clarity and consistency across functions. refactor(git): improve comments and simplify hook logic - Updated comments for clarity and consistency in the Git package. - Removed unnecessary constant `HookDocSite`, and clarified hook documentation URL logic. - Simplified the `GetHook` and `GetLang` functions to improve readability and error handling. - Updated the `supportedLangs` map to explicitly include `sh` and `bash`, ensuring clearer intent. feat(util): add file ops, prompts, and config functions - Added utility functions for terminal prompts, including YesNoPrompt and UserInputPrompt, to improve user interaction. - Expanded file handling functions, including CreateDirectory and CopyFile, to support additional use cases. - Introduced functions to handle HkUp configuration paths: - GetConfigDirPath - GetConfigFilePath - GetTemplateDirPath - Added functions for TOML file manipulation: - GetTOMLValue (retrieve a value from a TOML file) - SetTOMLValue (set a value in a TOML file) - Implemented GetEditor function to determine the default editor for HkUp from configuration, git, or environment variables. - Refactored existing functions for clarity and consistency (e.g., CreateFile, DoesDirectoryExist).
- 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.