diff --git a/random/files/random-files/README.md b/random/files/random-files/README.md index eeb2087..8f60dfa 100644 --- a/random/files/random-files/README.md +++ b/random/files/random-files/README.md @@ -101,4 +101,4 @@ Note: Specifying the same seed will produce the same results. ### Acknowledgments -Credit to Juan Benet as the author of [`go-random-files`](https://github.com/jbenet/go-random-files) from which this code was derived. +Credit to [Juan Benet](https://github.com/jbenet) as the author of [`go-random-files`](https://github.com/jbenet/go-random-files) from which this code was derived. diff --git a/random/files/random-files/main.go b/random/files/random-files/main.go index cb3ea43..0c8ca0a 100644 --- a/random/files/random-files/main.go +++ b/random/files/random-files/main.go @@ -9,13 +9,17 @@ import ( ) func main() { - var usage = `usage: %s [options] ... -Write a random filesystem hierarchy to each + var usage = `NAME + %s - Write a random filesystem hierarchy to each -Options: +USAGE + %s [options] ... + +OPTIONS: ` flag.Usage = func() { - fmt.Fprintf(os.Stderr, usage, os.Args[0]) + cmd := os.Args[0] + fmt.Fprintf(os.Stderr, usage, cmd, cmd) flag.PrintDefaults() } @@ -31,9 +35,9 @@ Options: flag.Int64Var(&cfg.FileSize, "filesize", cfg.FileSize, "bytes of random data in each file") flag.IntVar(&cfg.Dirs, "dirs", cfg.Dirs, "number of subdirectories at each depth") flag.IntVar(&cfg.Files, "files", cfg.Files, "number of files at each depth") - flag.BoolVar(&cfg.RandomDirs, "random-dirs", cfg.RandomDirs, "randomize number of subdirectories, from 1 to -Dirs") - flag.BoolVar(&cfg.RandomFiles, "random-files", cfg.RandomFiles, "randomize number of files, from 1 to -Files") - flag.BoolVar(&cfg.RandomSize, "random-size", cfg.RandomSize, "randomize file size, from 1 to -FileSize") + flag.BoolVar(&cfg.RandomDirs, "random-dirs", cfg.RandomDirs, "randomize number of subdirectories, from 1 to -dirs") + flag.BoolVar(&cfg.RandomFiles, "random-files", cfg.RandomFiles, "randomize number of files, from 1 to -files") + flag.BoolVar(&cfg.RandomSize, "random-size", cfg.RandomSize, "randomize file size, from 1 to -filesize") flag.Int64Var(&cfg.Seed, "seed", cfg.Seed, "random seed, 0 for current time") flag.Parse() @@ -46,6 +50,10 @@ Options: err := files.Create(cfg, paths...) if err != nil { fmt.Fprintln(os.Stderr, "error:", err) + if len(paths) < 1 { + fmt.Fprintln(os.Stderr) + flag.Usage() + } os.Exit(1) } }