flaggy icon indicating copy to clipboard operation
flaggy copied to clipboard

Consider allowing users to pass in structs of options

Open integrii opened this issue 6 years ago • 3 comments

It could be convenient to pass in a pointer to a struct for options. Flaggy could loop over the struct fields, and depending on the property type and name, assign variables into it.

integrii avatar May 09 '18 20:05 integrii

Or using tags:

type Options struct {
  Name       string `flaggy:"n,name,rest is description"` // short=n, long=name
  Address    string `flaggy:",address"`                   // no short, long=address, without description
  Subscribed bool   `flaggy:"s"`                          // short=s, no long, without description
  Quiet      bool   `flaggy:"q,,quiet mode"`              // short=q, no long
}

maxatome avatar Jul 11 '18 09:07 maxatome

I am leaning toward calling this "out of scope" for flaggy because its so radically different than the currently patterns. I think go-flags already does a pretty good job of this.

The user experience will likely suffer if there are too many ways to do things.

I'm leaving this open for now for more discussion.

integrii avatar Jul 12 '18 02:07 integrii

(fig)[https://github.com/kkyr/fig] seems to do a better job at this by supporting subcommands however it makes sense for flaggy to have this.

olekukonko avatar May 21 '20 03:05 olekukonko