Last active
October 8, 2018 18:44
-
-
Save ninedraft/304e0a5e7d94935d2b574b5b33b58dd1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ( | |
gpflag "github.com/octago/sflags/gen/gpflag" | |
cobra "github.com/spf13/cobra" | |
) | |
type Flags struct { | |
// flag definitions here | |
// https://github.com/octago/sflags#flags-based-on-structures------ | |
} | |
func Command() *cobra.Command { | |
var flags Flags // default values can be defined here | |
var cmd = &cobra.Command{ | |
Use: "command", | |
Run: func(cmd *cobra.Command, args []string) { | |
// write your code here | |
}, | |
} | |
if err := gpflag.ParseTo(&flags, cmd.PersistentFlags()); err != nil { | |
panic(err) | |
} | |
return cmd | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment