You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
import (
"log"
"github.com/spf13/cobra"
)
func main() {
var rootCmd = &cobra.Command{Use: "siknas-skylt"}
rootCmd.Flags().String("port", "8080", "The port the webserver should listen on")
if err := rootCmd.Execute(); err != nil {
log.Fatalln(err)
}
log.Println("Hello")
}
As I understand it by doing this I should get a --help flag automatically added.
Running with no flags
/go/src/bla # go-wrapper run
+ exec bla
2017/10/14 23:38:22 Hello
With --help flag
As you can see there is no help output and "Hello" is printed.
/go/src/bla # go-wrapper run --help
+ exec bla --help
2017/10/14 23:38:25 Hello
Invalid flag shows help
If I misspell help or try some other incorrect command I get the help output, which clearly states there's supposed to be a --help.
/go/src/bla # go-wrapper run --hel
+ exec bla --hel
Error: unknown flag: --hel
Usage:
Flags:
-h, --help help for siknas-skylt
--port string The port the webserver should listen on (default "8080")
2017/10/14 23:38:28 unknown flag: --hel
Am I missing something obvious or is this a bug?
The text was updated successfully, but these errors were encountered:
As I understand it by doing this I should get a
--help
flag automatically added.Running with no flags
With --help flag
As you can see there is no help output and "Hello" is printed.
Invalid flag shows help
If I misspell
help
or try some other incorrect command I get the help output, which clearly states there's supposed to be a--help
.Am I missing something obvious or is this a bug?
The text was updated successfully, but these errors were encountered: