54 lines
1.4 KiB
Go
54 lines
1.4 KiB
Go
/*
|
|
Copyright © 2024 NAME HERE <EMAIL ADDRESS>
|
|
*/
|
|
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"git.faercol.me/faercol/http-boot-config/config/config"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
// remoteCmd represents the remote command
|
|
var remoteCmd = &cobra.Command{
|
|
Use: "remote",
|
|
Short: "Get status of remote server",
|
|
Long: `A longer description that spans multiple lines and likely contains examples
|
|
and usage of using your command. For example:
|
|
|
|
Cobra is a CLI library for Go that empowers applications.
|
|
This application is a tool to generate the needed files
|
|
to quickly create a Cobra application.`,
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
getRemoteStatus()
|
|
},
|
|
}
|
|
|
|
func getRemoteStatus() {
|
|
conf, err := config.Get()
|
|
if err != nil {
|
|
fmt.Fprintf(os.Stderr, "Failed to get boot client configuration: %s\n", err.Error())
|
|
os.Exit(1)
|
|
}
|
|
|
|
if !conf.Enrolled {
|
|
fmt.Println("Boot service has not been configured yet.")
|
|
os.Exit(0)
|
|
}
|
|
}
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(remoteCmd)
|
|
|
|
// Here you will define your flags and configuration settings.
|
|
|
|
// Cobra supports Persistent Flags which will work for this command
|
|
// and all subcommands, e.g.:
|
|
// remoteCmd.PersistentFlags().String("foo", "", "A help for foo")
|
|
|
|
// Cobra supports local flags which will only run when this command
|
|
// is called directly, e.g.:
|
|
// remoteCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
|
}
|