Skip to content

Commit

Permalink
refactor(cmd)!: unexport cmd call back functions
Browse files Browse the repository at this point in the history
  • Loading branch information
muthukrishnan24 committed Sep 29, 2021
1 parent 79edbb8 commit 7153a46
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
20 changes: 10 additions & 10 deletions cmd/callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ const (
ErrExitCode = 1
)

// Init is the callback function for init command
func Init(confPath string, isGlobal, isReplace bool) error {
// initLint is the callback function for init command
func initLint(confPath string, isGlobal, isReplace bool) error {
hookDir, err := initHooks(confPath, isGlobal, isReplace)
if err != nil {
return err
}
return setGitConf(hookDir, isGlobal)
}

// Lint is the callback function for lint command
func Lint(confPath, msgPath string) error {
// lintMsg is the callback function for lint command
func lintMsg(confPath, msgPath string) error {
// NOTE: lint should return with exit code for error case
resStr, hasError, err := runLint(confPath, msgPath)
if err != nil {
Expand All @@ -40,20 +40,20 @@ func Lint(confPath, msgPath string) error {
return nil
}

// HookCreate is the callback function for create hook command
func HookCreate(confPath string, isReplace bool) error {
// hookCreate is the callback function for create hook command
func hookCreate(confPath string, isReplace bool) error {
return createHooks(confPath, isReplace)
}

// ConfigCreate is the callback function for create config command
func ConfigCreate(onlyEnabled bool) error {
// configCreate is the callback function for create config command
func configCreate(onlyEnabled bool) error {
defConf := config.GetDefaultConf(onlyEnabled)
outPath := filepath.Join(".", config.DefaultFile)
return config.WriteConfToFile(outPath, defConf)
}

// ConfigCheck is the callback function for check/verify command
func ConfigCheck(confPath string) error {
// configCheck is the callback function for check/verify command
func configCheck(confPath string) error {
conf, err := config.Parse(confPath)
if err != nil {
return err
Expand Down
10 changes: 5 additions & 5 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func lintCmd() *cli.Command {
Action: func(ctx *cli.Context) error {
confFilePath := ctx.String("config")
fileInput := ctx.String("message")
return Lint(confFilePath, fileInput)
return lintMsg(confFilePath, fileInput)
},
}
}
Expand All @@ -77,7 +77,7 @@ func initCmd() *cli.Command {
isGlobal := ctx.Bool("global")
isReplace := ctx.Bool("replace")

err := Init(confPath, isGlobal, isReplace)
err := initLint(confPath, isGlobal, isReplace)
if err != nil {
if isHookExists(err) {
fmt.Println("commitlint init failed")
Expand Down Expand Up @@ -107,7 +107,7 @@ func configCmd() *cli.Command {
},
Action: func(ctx *cli.Context) error {
isOnlyEnabled := ctx.Bool("enabled")
return ConfigCreate(isOnlyEnabled)
return configCreate(isOnlyEnabled)
},
}

Expand All @@ -124,7 +124,7 @@ func configCmd() *cli.Command {
},
Action: func(ctx *cli.Context) error {
confFile := ctx.String("config")
err := ConfigCheck(confFile)
err := configCheck(confFile)
if err != nil {
return err
}
Expand All @@ -151,7 +151,7 @@ func hookCmd() *cli.Command {
Action: func(ctx *cli.Context) error {
confPath := ctx.String("config")
isReplace := ctx.Bool("replace")
err := HookCreate(confPath, isReplace)
err := hookCreate(confPath, isReplace)
if err != nil {
if isHookExists(err) {
fmt.Println("create failed. hook files already exists")
Expand Down

0 comments on commit 7153a46

Please sign in to comment.