blob: d616714acafdf999407529166ab4749ab2776cc7 [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 Zalegab2cac082022-07-14 14:55:43 +020024 // verbose, if set, will make this utility log additional runtime
25 // information.
26 verbose bool
Mateusz Zalegad5f2f7a2022-07-05 18:48:56 +020027}
28
29var flags metroctlFlags
30
31func init() {
32 rootCmd.PersistentFlags().StringArrayVar(&flags.clusterEndpoints, "endpoints", nil, "A list of the target cluster's endpoints.")
Mateusz Zalegaf7774962022-07-08 12:26:55 +020033 rootCmd.PersistentFlags().StringVar(&flags.proxyAddr, "proxy", "", "SOCKS5 proxy address")
Mateusz Zalega8234c162022-07-08 17:05:50 +020034 rootCmd.PersistentFlags().StringVar(&flags.configPath, "config", filepath.Join(xdg.ConfigHome, "metroctl"), "An alternative cluster config path")
Mateusz Zalegab2cac082022-07-14 14:55:43 +020035 rootCmd.PersistentFlags().BoolVar(&flags.verbose, "verbose", false, "Log additional runtime information")
Mateusz Zalegad5f2f7a2022-07-05 18:48:56 +020036}
37
Lorenz Brun6adf8842021-10-05 13:39:11 +020038func main() {
39 cobra.CheckErr(rootCmd.Execute())
40}