blob: 7c1e050819523c72f643bc8af67bb9fbe8e55e8c [file] [log] [blame]
Lorenz Brun6adf8842021-10-05 13:39:11 +02001package main
2
3import (
Mateusz Zalega8234c162022-07-08 17:05:50 +02004 "path/filepath"
5
6 "github.com/adrg/xdg"
Lorenz Brun6adf8842021-10-05 13:39:11 +02007 "github.com/spf13/cobra"
8)
9
10// rootCmd represents the base command when called without any subcommands
11var rootCmd = &cobra.Command{
12 Use: "metroctl",
13 Short: "metroctl controls Metropolis nodes and clusters.",
14}
15
Mateusz Zalegad5f2f7a2022-07-05 18:48:56 +020016type metroctlFlags struct {
17 // clusterEndpoints is a list of the targeted cluster's endpoints, used by
18 // commands that perform RPC on it.
19 clusterEndpoints []string
Mateusz Zalegaf7774962022-07-08 12:26:55 +020020 // proxyAddr is a SOCKS5 proxy address the cluster will be accessed through.
21 proxyAddr string
Mateusz Zalega8234c162022-07-08 17:05:50 +020022 // configPath overrides the default XDG config path
23 configPath string
Mateusz Zalegad5f2f7a2022-07-05 18:48:56 +020024}
25
26var flags metroctlFlags
27
28func init() {
29 rootCmd.PersistentFlags().StringArrayVar(&flags.clusterEndpoints, "endpoints", nil, "A list of the target cluster's endpoints.")
Mateusz Zalegaf7774962022-07-08 12:26:55 +020030 rootCmd.PersistentFlags().StringVar(&flags.proxyAddr, "proxy", "", "SOCKS5 proxy address")
Mateusz Zalega8234c162022-07-08 17:05:50 +020031 rootCmd.PersistentFlags().StringVar(&flags.configPath, "config", filepath.Join(xdg.ConfigHome, "metroctl"), "An alternative cluster config path")
Mateusz Zalegad5f2f7a2022-07-05 18:48:56 +020032}
33
Lorenz Brun6adf8842021-10-05 13:39:11 +020034func main() {
35 cobra.CheckErr(rootCmd.Execute())
36}