mirror of
https://github.com/JaCoB1123/dupe-finder.git
synced 2026-11-12 23:11:02 +01:00
fix: check supplied paths on startup and mention paths in usage
This commit is contained in:
1 parent
68eb049262
commit
99f06f8429
1 file changed
+21
@@ -29,8 +29,15 @@ var verbose = flag.Bool("verbose", false, "Output additional information")
|
|||||||
var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
|
var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
flag.Usage = printUsage
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
if err := validateSearchPaths(flag.Args()); err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "error: %v\n\n", err)
|
||||||
|
flag.Usage()
|
||||||
|
os.Exit(2)
|
||||||
|
}
|
||||||
|
|
||||||
if *cpuprofile != "" {
|
if *cpuprofile != "" {
|
||||||
f, err := os.Create(*cpuprofile)
|
f, err := os.Create(*cpuprofile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -242,3 +249,17 @@ func printConfiguration() {
|
|||||||
fmt.Println()
|
fmt.Println()
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func printUsage() {
|
||||||
|
fmt.Fprintf(flag.CommandLine.Output(), "Usage: %s [options] <path> [<path> ...]\n", os.Args[0])
|
||||||
|
flag.PrintDefaults()
|
||||||
|
}
|
||||||
|
|
||||||
|
func validateSearchPaths(paths []string) error {
|
||||||
|
for _, path := range paths {
|
||||||
|
if _, err := os.Stat(path); err != nil {
|
||||||
|
return fmt.Errorf("cannot access search path %q: %w", path, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
Reference in new issue
Block a user