define custom usage handler.

This commit is contained in:
onyx-and-iris 2024-07-02 10:54:27 +01:00
parent 6211531f87
commit 0bfc1e62ba
2 changed files with 12 additions and 10 deletions

View File

@ -12,7 +12,7 @@ Commands that begin with `!` will toggle a parameter, commands that contain `=`
You may pass the following optional flags: You may pass the following optional flags:
- -h: Print the help dialogue - -h: Print the help message
- -i: Enable interactive mode - -i: Enable interactive mode
- -k: The kind of Voicemeeter GUI to launch, defaults to Banana - -k: The kind of Voicemeeter GUI to launch, defaults to Banana
- -l: Log level (0 up to 6), defaults to 3, Warn Level - -l: Log level (0 up to 6), defaults to 3, Warn Level

View File

@ -54,8 +54,10 @@ func main() {
help bool help bool
) )
flag.BoolVar(&help, "help", false, "print the help dialogue") flag.Usage = usage
flag.BoolVar(&help, "h", false, "print the help dialogue (shorthand)")
flag.BoolVar(&help, "help", false, "print the help message")
flag.BoolVar(&help, "h", false, "print the help message (shorthand)")
flag.StringVar(&kind, "kind", "banana", "kind of voicemeeter") flag.StringVar(&kind, "kind", "banana", "kind of voicemeeter")
flag.StringVar(&kind, "k", "banana", "kind of voicemeeter (shorthand)") flag.StringVar(&kind, "k", "banana", "kind of voicemeeter (shorthand)")
flag.IntVar(&delay, "delay", 20, "delay between commands") flag.IntVar(&delay, "delay", 20, "delay between commands")
@ -64,12 +66,12 @@ func main() {
flag.BoolVar(&interactive, "i", false, "toggle interactive mode (shorthand)") flag.BoolVar(&interactive, "i", false, "toggle interactive mode (shorthand)")
flag.IntVar(&loglevel, "loglevel", int(log.WarnLevel), "set the log level") flag.IntVar(&loglevel, "loglevel", int(log.WarnLevel), "set the log level")
flag.IntVar(&loglevel, "l", int(log.WarnLevel), "set the log level (shorthand)") flag.IntVar(&loglevel, "l", int(log.WarnLevel), "set the log level (shorthand)")
flag.BoolVar(&vPrinter.verbose, "verbose", false, "toggle console output") flag.BoolVar(&vPrinter.verbose, "verbose", false, "enable extra console output (toggle and set messages)")
flag.BoolVar(&vPrinter.verbose, "v", false, "toggle console output (shorthand)") flag.BoolVar(&vPrinter.verbose, "v", false, "enable extra console output (toggle and set messages) (shorthand)")
flag.Parse() flag.Parse()
if help { if help {
help_dialogue() flag.Usage()
return return
} }
@ -90,7 +92,7 @@ func main() {
args := flag.Args() args := flag.Args()
if len(args) == 0 { if len(args) == 0 {
help_dialogue() flag.Usage()
return return
} }
@ -101,10 +103,10 @@ func main() {
} }
} }
func help_dialogue() { func usage() {
fmt.Printf("usage: ./vm-cli [-h] [-i] [-k] [-l] [-d] [-v]\n" + fmt.Println("usage: ./vm-cli.exe [-h] [-i] [-k] [-l] [-d] [-v]\n" +
"Where:\n" + "Where:\n" +
"\th: Print the help dialogue\n" + "\th: Print the help message\n" +
"\ti: Enable interactive mode\n" + "\ti: Enable interactive mode\n" +
"\tk: The kind of Voicemeeter GUI to launch, defaults to Banana\n" + "\tk: The kind of Voicemeeter GUI to launch, defaults to Banana\n" +
"\tl: Log level 0 up to 6, (defaults to 3, Warn Level)\n" + "\tl: Log level 0 up to 6, (defaults to 3, Warn Level)\n" +