-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
Based on what I've read in the documentation I would expect the following to work, but I might have misconfigured something. Essentially I would like to support syntax like what git exposes, ala git status --short command.
Here's some sample code:
connection := ""
migrations := ""
getopt.FlagLong(&connection, "connection", 'c', "SQL connection string")
getopt.FlagLong(&migrations, "migrations", 'm', "Migrations directory")
getopt.Parse()
config := MigConfig{
Connection: connection,
Migrations: migrations,
}
args := getopt.Args()
fmt.Println("CONFIG")
fmt.Println(config)
fmt.Println("ARGS")
fmt.Println(args)
return config, nilNext, I'm invoking the program in two ways:
$ app status --connection="foo"
CONFIG
{ }
ARGS
[status --connection=foo]
$ app --connection="foo" status
CONFIG
{foo }
ARGS
[status]
The second invocation works as expected, pulling the flag data out and providing the remaining non-flag arguments via .Args(). However the first invocation, in the style of the git command, wasn't able to parse the flags. Have I configured this wrong or is this expected behavior?
Metadata
Metadata
Assignees
Labels
No labels