From 7153a46032a229c6f0a0da89e516e0d53deae114 Mon Sep 17 00:00:00 2001 From: muthukrishnan24 Date: Wed, 29 Sep 2021 18:26:04 +0530 Subject: [PATCH] refactor(cmd)!: unexport cmd call back functions --- cmd/callback.go | 20 ++++++++++---------- cmd/cmd.go | 10 +++++----- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/cmd/callback.go b/cmd/callback.go index f493702..ddbaf97 100644 --- a/cmd/callback.go +++ b/cmd/callback.go @@ -14,8 +14,8 @@ 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 @@ -23,8 +23,8 @@ func Init(confPath string, isGlobal, isReplace bool) error { 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 { @@ -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 diff --git a/cmd/cmd.go b/cmd/cmd.go index 6d72547..6706ad9 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -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) }, } } @@ -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") @@ -107,7 +107,7 @@ func configCmd() *cli.Command { }, Action: func(ctx *cli.Context) error { isOnlyEnabled := ctx.Bool("enabled") - return ConfigCreate(isOnlyEnabled) + return configCreate(isOnlyEnabled) }, } @@ -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 } @@ -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")