From 22dd0bb59717f971aa9a19d1823360b0c21402ea Mon Sep 17 00:00:00 2001 From: bilou4 <4quatre4quatre@gmail.com> Date: Wed, 10 Apr 2024 20:37:59 +0200 Subject: [PATCH] [feature/recursivity] removed useless three dots operator --- cmd/hash.go | 3 +-- cmd/md5Hash.go | 3 +-- cmd/root.go | 12 ------------ cmd/sha1Hash.go | 3 +-- cmd/sha224Hash.go | 3 +-- cmd/sha256Hash.go | 3 +-- cmd/sha384Hash.go | 3 +-- cmd/sha512Hash.go | 3 +-- 8 files changed, 7 insertions(+), 26 deletions(-) diff --git a/cmd/hash.go b/cmd/hash.go index 1c04521..e7869fd 100644 --- a/cmd/hash.go +++ b/cmd/hash.go @@ -26,8 +26,7 @@ var hashCmd = &cobra.Command{ Long: `The hash command computes the hash of a given FILE. Without FILE or when FILE is '-', read the standard input. -If the list of FILE contains a directory, it will be proceed recursively. -If the list of FILE contains './...' it will proceed directories recursively from the current directory.`, +If the list of FILE contains a directory, it will be proceed recursively.`, SilenceErrors: true, } diff --git a/cmd/md5Hash.go b/cmd/md5Hash.go index aa99394..ccad4e5 100644 --- a/cmd/md5Hash.go +++ b/cmd/md5Hash.go @@ -13,8 +13,7 @@ var md5HashCmd = &cobra.Command{ Long: `Display MD5 checksums (128 bits). Without FILE or when FILE is '-', read the standard input. -If the list of FILE contains a directory, it will be proceed recursively. -If the list of FILE contains './...' it will proceed directories recursively from the current directory.`, +If the list of FILE contains a directory, it will be proceed recursively.`, RunE: func(cmd *cobra.Command, args []string) error { filesToCheck, err := getFilesToCompute(args) if err != nil { diff --git a/cmd/root.go b/cmd/root.go index 476f555..4867aee 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -7,7 +7,6 @@ import ( "os" "path/filepath" "runtime" - "slices" "github.com/spf13/cobra" ) @@ -38,21 +37,10 @@ func remove(s []string, i int) []string { } func getFilesToCompute(args []string) ([]string, error) { - var err error if len(args) == 0 || (len(args) == 1 && args[0] == "-") { return []string{"-"}, nil } - // Here ./ tells to start from the current folder, ... tells to go down recursively. - if slices.Contains(args, "./...") { - idx := slices.Index(args, "./...") - args = remove(args, idx) - args, err = computeDirRecursively(args, ".") - if err != nil { - return nil, err - } - } - // check for dirs and all files exist for idx, elem := range args { f, err := os.Open(elem) diff --git a/cmd/sha1Hash.go b/cmd/sha1Hash.go index 6ba6666..690f427 100644 --- a/cmd/sha1Hash.go +++ b/cmd/sha1Hash.go @@ -13,8 +13,7 @@ var sha1HashCmd = &cobra.Command{ Long: `Display SHA-1 checksums (160 bits). Without FILE or when FILE is '-', read the standard input. -If the list of FILE contains a directory, it will be proceed recursively. -If the list of FILE contains './...' it will proceed directories recursively from the current directory.`, +If the list of FILE contains a directory, it will be proceed recursively.`, RunE: func(cmd *cobra.Command, args []string) error { filesToCheck, err := getFilesToCompute(args) if err != nil { diff --git a/cmd/sha224Hash.go b/cmd/sha224Hash.go index 6203abd..81062e1 100644 --- a/cmd/sha224Hash.go +++ b/cmd/sha224Hash.go @@ -13,8 +13,7 @@ var sha224HashCmd = &cobra.Command{ Long: `Display SHA-224 checksums (224 bits). Without FILE or when FILE is '-', read the standard input. -If the list of FILE contains a directory, it will be proceed recursively. -If the list of FILE contains './...' it will proceed directories recursively from the current directory.`, +If the list of FILE contains a directory, it will be proceed recursively.`, RunE: func(cmd *cobra.Command, args []string) error { filesToCheck, err := getFilesToCompute(args) if err != nil { diff --git a/cmd/sha256Hash.go b/cmd/sha256Hash.go index b8ee720..a3d7157 100644 --- a/cmd/sha256Hash.go +++ b/cmd/sha256Hash.go @@ -13,8 +13,7 @@ var sha256HashCmd = &cobra.Command{ Long: `Display SHA256 checksums (256 bits). Without FILE or when FILE is '-', read the standard input. -If the list of FILE contains a directory, it will be proceed recursively. -If the list of FILE contains './...' it will proceed directories recursively from the current directory.`, +If the list of FILE contains a directory, it will be proceed recursively.`, RunE: func(cmd *cobra.Command, args []string) error { filesToCheck, err := getFilesToCompute(args) if err != nil { diff --git a/cmd/sha384Hash.go b/cmd/sha384Hash.go index 1cbf37f..9e1630a 100644 --- a/cmd/sha384Hash.go +++ b/cmd/sha384Hash.go @@ -13,8 +13,7 @@ var sha384HashCmd = &cobra.Command{ Long: `Display SHA-384 checksums (384 bits). Without FILE or when FILE is '-', read the standard input. -If the list of FILE contains a directory, it will be proceed recursively. -If the list of FILE contains './...' it will proceed directories recursively from the current directory.`, +If the list of FILE contains a directory, it will be proceed recursively.`, RunE: func(cmd *cobra.Command, args []string) error { filesToCheck, err := getFilesToCompute(args) if err != nil { diff --git a/cmd/sha512Hash.go b/cmd/sha512Hash.go index 75af1eb..8fba1c0 100644 --- a/cmd/sha512Hash.go +++ b/cmd/sha512Hash.go @@ -13,8 +13,7 @@ var sha512HashCmd = &cobra.Command{ Long: `Display SHA-512 checksums (512 bits). Without FILE or when FILE is '-', read the standard input. -If the list of FILE contains a directory, it will be proceed recursively. -If the list of FILE contains './...' it will proceed directories recursively from the current directory.`, +If the list of FILE contains a directory, it will be proceed recursively.`, RunE: func(cmd *cobra.Command, args []string) error { filesToCheck, err := getFilesToCompute(args) if err != nil {