Skip to content

Commit

Permalink
[feature/recursivity] removed useless three dots operator
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilou4 committed Apr 10, 2024
1 parent 7fa726d commit 22dd0bb
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 26 deletions.
3 changes: 1 addition & 2 deletions cmd/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down
3 changes: 1 addition & 2 deletions cmd/md5Hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 0 additions & 12 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"os"
"path/filepath"
"runtime"
"slices"

"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions cmd/sha1Hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions cmd/sha224Hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions cmd/sha256Hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions cmd/sha384Hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions cmd/sha512Hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 22dd0bb

Please sign in to comment.