From 8063fbb0eebce00d43d585f568e32a23eacf0e2c Mon Sep 17 00:00:00 2001 From: iton0 Date: Tue, 31 Dec 2024 17:05:59 -0500 Subject: [PATCH] refactor: minor tweaks --- cmd/config/root.go | 4 +--- cmd/template/root.go | 4 +--- internal/logic/list.go | 4 ++-- internal/util/main.go | 6 ++---- main.go | 4 +--- 5 files changed, 7 insertions(+), 15 deletions(-) diff --git a/cmd/config/root.go b/cmd/config/root.go index 28bae8d..9a8799a 100644 --- a/cmd/config/root.go +++ b/cmd/config/root.go @@ -1,8 +1,6 @@ package config -import ( - "github.com/spf13/cobra" -) +import "github.com/spf13/cobra" // RootCmd is the root config subcommand that will be added to the root HkUp // command. diff --git a/cmd/template/root.go b/cmd/template/root.go index 2cded6b..2b73589 100644 --- a/cmd/template/root.go +++ b/cmd/template/root.go @@ -1,8 +1,6 @@ package template -import ( - "github.com/spf13/cobra" -) +import "github.com/spf13/cobra" // RootCmd is the root template subcommand that will be added to the root HkUp // command. diff --git a/internal/logic/list.go b/internal/logic/list.go index c68ffdc..8b6690a 100644 --- a/internal/logic/list.go +++ b/internal/logic/list.go @@ -73,13 +73,13 @@ func getHookTemplates() []string { // getCwdHooks returns the hooks in the current working directory. // If no hooks are found, returns a empty string slice. func getCwdHooks() []string { - out := []string{} - files, err := os.ReadDir(util.HkupDirName) if err != nil { return nil } + out := []string{} + for _, file := range files { out = append(out, file.Name()) } diff --git a/internal/util/main.go b/internal/util/main.go index cf9a2d8..b0630c2 100644 --- a/internal/util/main.go +++ b/internal/util/main.go @@ -26,10 +26,8 @@ import ( "strings" ) -const ( - // HkupDirName defines HkUp directory name within current working directory. - HkupDirName = ".hkup" -) +// HkupDirName defines HkUp directory name within current working directory. +const HkupDirName = ".hkup" // CreateDirectory makes a new directory at the specified path. // Returns an error if the operation fails. diff --git a/main.go b/main.go index 7a97bb0..232951f 100644 --- a/main.go +++ b/main.go @@ -1,9 +1,7 @@ // Package main initializes Cobra package main -import ( - "github.com/iton0/hkup-cli/cmd" -) +import "github.com/iton0/hkup-cli/cmd" func main() { cmd.Execute()