{"action":"created","issue":{"url":"https://api.github.com/repos/spf13/pflag/issues/95","repository_url":"https://api.github.com/repos/spf13/pflag","labels_url":"https://api.github.com/repos/spf13/pflag/issues/95/labels{/name}","comments_url":"https://api.github.com/repos/spf13/pflag/issues/95/comments","events_url":"https://api.github.com/repos/spf13/pflag/issues/95/events","html_url":"https://github.com/spf13/pflag/issues/95","id":179840239,"number":95,"title":"Grouping flags?","user":{"login":"fd0","id":123276,"avatar_url":"https://avatars2.githubusercontent.com/u/123276?v=3","gravatar_id":"","url":"https://api.github.com/users/fd0","html_url":"https://github.com/fd0","followers_url":"https://api.github.com/users/fd0/followers","following_url":"https://api.github.com/users/fd0/following{/other_user}","gists_url":"https://api.github.com/users/fd0/gists{/gist_id}","starred_url":"https://api.github.com/users/fd0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fd0/subscriptions","organizations_url":"https://api.github.com/users/fd0/orgs","repos_url":"https://api.github.com/users/fd0/repos","events_url":"https://api.github.com/users/fd0/events{/privacy}","received_events_url":"https://api.github.com/users/fd0/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2016-09-28T17:48:36Z","updated_at":"2017-03-26T08:51:49Z","closed_at":"2017-03-26T08:12:08Z","body":"Hi,\n\nis it possible to group flags so that they appear together in the `--help` text? I'm using `pflag` in my [backup program](https://github.com/restic/restic), there I have for example the options to expire backups according to a policy. Before (with the `go-flags`) library the options were nicely grouped together (in the order they were defined):\n\n```\n$ restic forget --help\nUsage:\n  restic [OPTIONS] forget [snapshot ID] ...\n[...]\n[forget command options]\n      -l, --keep-last=    keep the last n snapshots\n      -H, --keep-hourly=  keep the last n hourly snapshots\n      -d, --keep-daily=   keep the last n daily snapshots\n      -w, --keep-weekly=  keep the last n weekly snapshots\n      -m, --keep-monthly= keep the last n monthly snapshots\n      -y, --keep-yearly=  keep the last n yearly snapshots\n          --keep-tag=     alwaps keep snapshots with this tag (can be specified multiple times)\n          --hostname=     only forget snapshots for the given hostname\n          --tag=          only forget snapshots with the tag (can be specified multiple times)\n      -n, --dry-run       do not delete anything, just print what would be done\n```\n\nNow with `pflag` and `cobra` they are printed in alphabetical order:\n\n```\n[...]\nUsage:\n  restic forget [flags] [snapshot ID] [...]\n\nFlags:\n  -n, --dry-run                do not delete anything, just print what would be done\n      --hostname string        only forget snapshots for the given hostname\n  -d, --keep-daily int         keep the last n daily snapshots\n  -H, --keep-hourly int        keep the last n hourly snapshots\n  -l, --keep-last int          keep the last n snapshots\n  -m, --keep-monthly int       keep the last n monthly snapshots\n      --keep-tag stringSlice   always keep snapshots with this tag (can be specified multiple times)\n  -w, --keep-weekly int        keep the last n weekly snapshots\n  -y, --keep-yearly int        keep the last n yearly snapshots\n      --tag stringSlice        only forget snapshots with the tag (can be specified multiple times)\n[...]\n```\n\nIs there a way to group some flags so that they are printed together?\n"},"comment":{"url":"https://api.github.com/repos/spf13/pflag/issues/comments/289267041","html_url":"https://github.com/spf13/pflag/issues/95#issuecomment-289267041","issue_url":"https://api.github.com/repos/spf13/pflag/issues/95","id":289267041,"user":{"login":"fd0","id":123276,"avatar_url":"https://avatars2.githubusercontent.com/u/123276?v=3","gravatar_id":"","url":"https://api.github.com/users/fd0","html_url":"https://github.com/fd0","followers_url":"https://api.github.com/users/fd0/followers","following_url":"https://api.github.com/users/fd0/following{/other_user}","gists_url":"https://api.github.com/users/fd0/gists{/gist_id}","starred_url":"https://api.github.com/users/fd0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fd0/subscriptions","organizations_url":"https://api.github.com/users/fd0/orgs","repos_url":"https://api.github.com/users/fd0/repos","events_url":"https://api.github.com/users/fd0/events{/privacy}","received_events_url":"https://api.github.com/users/fd0/received_events","type":"User","site_admin":false},"created_at":"2017-03-26T08:51:49Z","updated_at":"2017-03-26T08:51:49Z","body":"There's also a bug: When you call `cmdRoot.LocalFlags()` before defining any flags, the help message is empty but the flags are still valid: https://gist.github.com/9cc52f7c0f5fc9d2cb84a1fcb43b11dc\r\n\r\n```\r\n$ go run main.go -h\r\nUsage:\r\n   [flags]\r\nerr: <nil>\r\n\r\n$ go run main.go -a foobar\r\ndo something\r\nerr: <nil>\r\n```"}}
{"actor":{"display_login":"fd0"}}