patchman/client/cmd/register.go

45 lines
1.4 KiB
Go

/*
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
*/
package cmd
import (
"fmt"
"github.com/spf13/viper"
"github.com/spf13/cobra"
)
// registerCmd represents the register command
var registerCmd = &cobra.Command{
Use: "register",
Short: "Register with server",
Long: `Register an endpoint with a patchman server:
patchman register --output /path/to/config --server https://patchman.example.com:443 --token <InsertRegistrationTokenHere>
`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("registering with Patchman Server")
viper.SetDefault("server", cmd.Flag("server"))
viper.SetConfigName("client.yaml")
viper.SetConfigType("yaml")
},
}
func init() {
rootCmd.AddCommand(registerCmd)
// Here you will define your flags and configuration settings.
// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// registerCmd.PersistentFlags().String("foo", "", "A help for foo")
// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// registerCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
registerCmd.Flags().String("output", "/etc/patchman/client.yaml", "Config file to create")
registerCmd.Flags().String("server", "", "URL to Patchman server")
registerCmd.Flags().String("token", "", "Registration token from Patchman Server")
}