Skip to content

Commit 739037f

Browse files
committed
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.
1 parent 116879f commit 739037f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

cmd/task/task.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ func main() {
4949

5050
var (
5151
versionFlag bool
52+
helpFlag bool
5253
init bool
5354
list bool
5455
status bool
@@ -65,6 +66,7 @@ func main() {
6566
)
6667

6768
pflag.BoolVar(&versionFlag, "version", false, "show Task version")
69+
pflag.BoolVarP(&helpFlag, "help", "h", false, "shows Task usage")
6870
pflag.BoolVarP(&init, "init", "i", false, "creates a new Taskfile.yml in the current folder")
6971
pflag.BoolVarP(&list, "list", "l", false, "lists tasks with description of current Taskfile")
7072
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() {
8587
return
8688
}
8789

90+
if helpFlag {
91+
pflag.Usage()
92+
return
93+
}
94+
8895
if init {
8996
wd, err := os.Getwd()
9097
if err != nil {

0 commit comments

Comments
 (0)