forked from tjarratt/babble
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
45 lines (37 loc) · 868 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package babble
import (
"flag"
"fmt"
"os"
)
var (
separator string
numberOfWords int
)
func init() {
flag.IntVar(&numberOfWords, "n", 3, "the number of random words to join")
flag.StringVar(&separator, "s", "-", "a separator to use when joining words")
}
// TODO: break the random word functionality into windows && unix helpers
func main() {
if len(os.Args) > 1 {
checkUsage()
}
flag.Parse()
babbler := NewBabbler()
babbler.Count = numberOfWords
babbler.Separator = separator
println(babbler.Babble())
return
}
func checkUsage() {
if os.Args[1] == "help" || os.Args[1] == "-h" || os.Args[1] == "--help" {
fmt.Printf(`
usage: babble -s [separator] -n [number-of-words]
eg: babble -s="-" -n=5 # holy-moly-guacamole-oily-strombole
The separator between words defaults to '-'
The number of words printed defaults to 3
`)
os.Exit(1)
}
}