Version and help commands.

This commit is contained in:
Justin Hawkins 2017-02-21 12:28:26 +10:30
parent 699ca9fcfc
commit cb1f1d1a05
2 changed files with 15 additions and 2 deletions

View File

@ -42,12 +42,19 @@ and the directory to watch:
`--directory /some/path/here` - the directory that screenshots will appear in. `--directory /some/path/here` - the directory that screenshots will appear in.
You will have to quote the path on windows, or anywhere where the directory path contains spaces. You will have to quote the path on windows, or anywhere where the directory path contains spaces. Note that
subdirectories will also be scanned.
Other parameters are: Other parameters are:
`--watch xx` - specify how many seconds to wait between scanning the directory. The default is 10 seconds. `--watch xx` - specify how many seconds to wait between scanning the directory. The default is 10 seconds.
`--username <username>` - an arbitrary string to show as the bot's username in the channel.
`--help` - show command line help.
`--version` - show the version.
## Limitations/bugs ## Limitations/bugs
* Only files ending jpg, gif or png are uploaded. * Only files ending jpg, gif or png are uploaded.

8
dau.go
View File

@ -96,13 +96,19 @@ func parse_options() (webhook_url string, path string, watch int, username strin
watchFlag := getopt.Int16Long ("watch", 's', 10, "time between scans") watchFlag := getopt.Int16Long ("watch", 's', 10, "time between scans")
usernameFlag := getopt.StringLong("username", 'u', "", "username for the bot upload") usernameFlag := getopt.StringLong("username", 'u', "", "username for the bot upload")
helpFlag := getopt.BoolLong ("help", 'h', "help") helpFlag := getopt.BoolLong ("help", 'h', "help")
versionFlag := getopt.BoolLong ("version", 'v', "show version")
getopt.SetParameters("") getopt.SetParameters("")
getopt.Parse() getopt.Parse()
if (*helpFlag) { if (*helpFlag) {
getopt.PrintUsage(os.Stderr) getopt.PrintUsage(os.Stderr)
os.Exit(1) os.Exit(0)
}
if (*versionFlag) {
fmt.Printf("Version: %s\n", current_version)
os.Exit(0)
} }
if ! getopt.IsSet("directory") { if ! getopt.IsSet("directory") {