github.com/nextlinux/gosbom@v0.81.1-0.20230627115839-1ff50c281391/cmd/gosbom/cli/options/attest.go (about) 1 package options 2 3 import ( 4 "github.com/spf13/cobra" 5 "github.com/spf13/pflag" 6 "github.com/spf13/viper" 7 ) 8 9 type AttestOptions struct { 10 Key string 11 } 12 13 var _ Interface = (*AttestOptions)(nil) 14 15 func (o AttestOptions) AddFlags(cmd *cobra.Command, v *viper.Viper) error { 16 cmd.Flags().StringVarP(&o.Key, "key", "k", "", "the key to use for the attestation") 17 return bindAttestConfigOptions(cmd.Flags(), v) 18 } 19 20 //nolint:revive 21 func bindAttestConfigOptions(flags *pflag.FlagSet, v *viper.Viper) error { 22 if err := v.BindPFlag("attest.key", flags.Lookup("key")); err != nil { 23 return err 24 } 25 return nil 26 }