Skip to content

Commit 2d31cf0

Browse files
authored
Update help text (#14)
1 parent cb2dfff commit 2d31cf0

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

random/files/random-files/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,4 @@ Note: Specifying the same seed will produce the same results.
101101

102102
### Acknowledgments
103103

104-
Credit to Juan Benet as the author of [`go-random-files`](https://github.com/jbenet/go-random-files) from which this code was derived.
104+
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.

random/files/random-files/main.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@ import (
99
)
1010

1111
func main() {
12-
var usage = `usage: %s [options] <path>...
13-
Write a random filesystem hierarchy to each <path>
12+
var usage = `NAME
13+
%s - Write a random filesystem hierarchy to each <path>
1414
15-
Options:
15+
USAGE
16+
%s [options] <path>...
17+
18+
OPTIONS:
1619
`
1720
flag.Usage = func() {
18-
fmt.Fprintf(os.Stderr, usage, os.Args[0])
21+
cmd := os.Args[0]
22+
fmt.Fprintf(os.Stderr, usage, cmd, cmd)
1923
flag.PrintDefaults()
2024
}
2125

@@ -31,9 +35,9 @@ Options:
3135
flag.Int64Var(&cfg.FileSize, "filesize", cfg.FileSize, "bytes of random data in each file")
3236
flag.IntVar(&cfg.Dirs, "dirs", cfg.Dirs, "number of subdirectories at each depth")
3337
flag.IntVar(&cfg.Files, "files", cfg.Files, "number of files at each depth")
34-
flag.BoolVar(&cfg.RandomDirs, "random-dirs", cfg.RandomDirs, "randomize number of subdirectories, from 1 to -Dirs")
35-
flag.BoolVar(&cfg.RandomFiles, "random-files", cfg.RandomFiles, "randomize number of files, from 1 to -Files")
36-
flag.BoolVar(&cfg.RandomSize, "random-size", cfg.RandomSize, "randomize file size, from 1 to -FileSize")
38+
flag.BoolVar(&cfg.RandomDirs, "random-dirs", cfg.RandomDirs, "randomize number of subdirectories, from 1 to -dirs")
39+
flag.BoolVar(&cfg.RandomFiles, "random-files", cfg.RandomFiles, "randomize number of files, from 1 to -files")
40+
flag.BoolVar(&cfg.RandomSize, "random-size", cfg.RandomSize, "randomize file size, from 1 to -filesize")
3741
flag.Int64Var(&cfg.Seed, "seed", cfg.Seed, "random seed, 0 for current time")
3842
flag.Parse()
3943

@@ -46,6 +50,10 @@ Options:
4650
err := files.Create(cfg, paths...)
4751
if err != nil {
4852
fmt.Fprintln(os.Stderr, "error:", err)
53+
if len(paths) < 1 {
54+
fmt.Fprintln(os.Stderr)
55+
flag.Usage()
56+
}
4957
os.Exit(1)
5058
}
5159
}

0 commit comments

Comments
 (0)