Files
threshold/internal/cmd/common/option.go
T
Jeff MalnickandJeff Mitchell a3c4cef648 Use primary auth method if no auth method ID is provided (#2725)
* feat: default to using primary auth method with authenticating

* Add ability to specify scope ID flag in authenticate method

---------

Co-authored-by: Jeff Mitchell <jeffrey.mitchell@gmail.com>
2023-01-31 10:07:10 -08:00

37 lines
770 B
Go

package common
// GetOpts - iterate the inbound Options and return a struct.
func GetOpts(opt ...Option) (*Options, error) {
opts := getDefaultOptions()
for _, o := range opt {
if o == nil {
continue
}
if err := o(opts); err != nil {
return nil, err
}
}
return opts, nil
}
// Option - how Options are passed as arguments.
type Option func(*Options) error
// Options - how Options are represented.
type Options struct {
WithSkipScopeIdFlag bool
}
func getDefaultOptions() *Options {
return &Options{}
}
// WithSkipScopeIdFlag tells a command to not create a scope ID flag (usually
// because it's already been defined)
func WithSkipScopeIdFlag(with bool) Option {
return func(o *Options) error {
o.WithSkipScopeIdFlag = with
return nil
}
}