Skip to content

boolean options don't seem to work #73

Open
@tmbdev

Description

Boolean options don't seem to work the way they should. Here is an example:

package main

import (
	"fmt"
	"github.com/docopt/docopt-go"
)

var usage string = `
Mytest.

Usage:
	mytest [options]

Options:
  --flag	a flag
`

func main() {
	opts, _ := docopt.ParseDoc(usage)
	flag, err := opts.Bool("--flag")
	fmt.Println(flag)
	fmt.Println(err)
}
$ go run mytest.go
false
key: "--flag" failed type conversion
$ go run mytest.go --flag
--flag requires argument
Usage:
	mytest [options]
exit status 1
$ go run mytest.go --flag=true
false
key: "--flag" failed type conversion
$ go version
go version go1.14.1 linux/amd64
$ 

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions