Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs about key-value-delimiter #417

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ line, you specify the value for such an option as key:value. For example
Then, the AuthorInfo map can be filled with something like
-a name:Jesse -a "surname:van den Kieboom".

You can also specify key-value-delimiter.

type Options struct {
AuthorInfo string[string] `short:"a" key-value-delimiter:"="`
}

In this case, the AuthorInfo map can be filled with something like
-a name=Jesse -a "surname=van den Kieboom".

Finally, for full control over the conversion between command line argument
values and options, user defined types can choose to implement the Marshaler
and Unmarshaler interfaces.
Expand Down Expand Up @@ -111,6 +120,10 @@ The following is a list of tags for struct fields supported by go-flags:
e.g. `long:"animal" choice:"cat" choice:"dog"`
hidden: if non-empty, the option is not visible in the help or man page.

key-value-delimiter: when specified on a map field, the key and the value are
separated with the given delimiter string,
instead of the default delimiter ":" (optional)

base: a base (radix) used to convert strings to integer values, the
default base is 10 (i.e. decimal) (optional)

Expand Down