Skip to content

Instantly share code, notes, and snippets.

@jrabbit
Created November 3, 2017 05:17
Show Gist options
  • Save jrabbit/d685136bc507dccfb6ee452a502224b2 to your computer and use it in GitHub Desktop.
Save jrabbit/d685136bc507dccfb6ee452a502224b2 to your computer and use it in GitHub Desktop.
package cmd
import (
"fmt"
"github.com/spf13/cobra"
)
var RootCmd = &cobra.Command{
Use: "task-client",
Short: " makes quick connections to taskd",
Run: func(cmd *cobra.Command, args []string) {
// Do Stuff Here
cmd.Help()
},
}
var Settings = make(map[string]string)
func init() {
var Server string
var Certificate string
var CACert string
var Key string
cobra.OnInitialize(initConfig)
RootCmd.PersistentFlags().StringVar(&Server, "server", "", "the taskd server to connect to")
RootCmd.PersistentFlags().StringVar(&Certificate, "certificate", "", "the user cert for auth")
RootCmd.PersistentFlags().StringVar(&CACert, "cacert", "", "the server's ca cert")
RootCmd.PersistentFlags().StringVar(&Key, "key", "", "the user key for auth")
Settings["taskd.server"] = Server
Settings["taskd.key"] = Key
Settings["taskd.certificate"] = Certificate
Settings["taskd.ca"] = CACert
fmt.Println(Settings)
}
func Execute() {
RootCmd.Execute()
}
func initConfig() {
return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment