Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package main

import (
"os"
"path/filepath"
"runtime"

"github.com/boyter/hashit/processor"
Expand All @@ -21,7 +22,18 @@ func main() {
Long: "Hash It!\nVersion " + processor.Version + "\nBen Boyter <ben@boyter.org>",
Version: processor.Version,
Run: func(cmd *cobra.Command, args []string) {
processor.DirFilePaths = args
var filePaths []string
for _, arg := range args {
matches, err := filepath.Glob(arg)
if err != nil || len(matches) == 0 {
// If there's an error or no matches, treat the argument as a literal path
filePaths = append(filePaths, arg)
} else {
filePaths = append(filePaths, matches...)
}
}

processor.DirFilePaths = filePaths
processor.Process()
},
}
Expand Down
9 changes: 9 additions & 0 deletions test-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ else
exit
fi

if ./hashit "*.go" | grep -q -i 'main.go'; then
echo -e "${GREEN}PASSED globbing test for *.go"
else
echo -e "${RED}======================================================="
echo -e "FAILED Globbing test for *.go"
echo -e "======================================================="
exit
fi

if ./hashit --debug --trace --verbose -f text --hash md5 --no-stream --stream-size 10 -r main.go > /dev/null ; then
echo -e "${GREEN}PASSED multiple options test"
else
Expand Down