1
0
mirror of https://github.com/go-task/task.git synced 2025-06-10 23:57:30 +02:00

Have the --help/-h flag print usage.

pflag will output a "pflag: help requested" message after displaying the usage
if we don't explicitly  handle the flag.
This commit is contained in:
Mads H. Danquah 2020-05-14 21:56:36 +02:00
parent 116879f7ea
commit 739037fc37

View File

@ -49,6 +49,7 @@ func main() {
var ( var (
versionFlag bool versionFlag bool
helpFlag bool
init bool init bool
list bool list bool
status bool status bool
@ -65,6 +66,7 @@ func main() {
) )
pflag.BoolVar(&versionFlag, "version", false, "show Task version") pflag.BoolVar(&versionFlag, "version", false, "show Task version")
pflag.BoolVarP(&helpFlag, "help", "h", false, "shows Task usage")
pflag.BoolVarP(&init, "init", "i", false, "creates a new Taskfile.yml in the current folder") pflag.BoolVarP(&init, "init", "i", false, "creates a new Taskfile.yml in the current folder")
pflag.BoolVarP(&list, "list", "l", false, "lists tasks with description of current Taskfile") pflag.BoolVarP(&list, "list", "l", false, "lists tasks with description of current Taskfile")
pflag.BoolVar(&status, "status", false, "exits with non-zero exit code if any of the given tasks is not up-to-date") pflag.BoolVar(&status, "status", false, "exits with non-zero exit code if any of the given tasks is not up-to-date")
@ -85,6 +87,11 @@ func main() {
return return
} }
if helpFlag {
pflag.Usage()
return
}
if init { if init {
wd, err := os.Getwd() wd, err := os.Getwd()
if err != nil { if err != nil {