Initial commit, pt. 63

This commit is contained in:
Dmitrii Okunev
2024-08-04 00:41:52 +01:00
parent 6b83facd80
commit 589dc9684e
4 changed files with 62 additions and 19 deletions

View File

@@ -75,6 +75,16 @@ var (
Run: variablesSet,
}
Config = &cobra.Command{
Use: "config",
}
ConfigGet = &cobra.Command{
Use: "get",
Args: cobra.ExactArgs(0),
Run: configGet,
}
LoggerLevel = logger.LevelWarning
)
@@ -88,6 +98,9 @@ func init() {
Variables.AddCommand(VariablesGetHash)
Variables.AddCommand(VariablesSet)
Root.AddCommand(Config)
Config.AddCommand(ConfigGet)
Root.PersistentFlags().Var(&LoggerLevel, "log-level", "")
Root.PersistentFlags().String("remote-addr", "localhost:3594", "the path to the config file")
StreamSetup.PersistentFlags().String("title", "", "stream title")
@@ -212,3 +225,16 @@ func variablesSet(cmd *cobra.Command, args []string) {
err = streamD.SetVariable(ctx, consts.VarKey(variableKey), value)
assertNoError(ctx, err)
}
func configGet(cmd *cobra.Command, args []string) {
ctx := cmd.Context()
remoteAddr, err := cmd.Flags().GetString("remote-addr")
assertNoError(ctx, err)
streamD := client.New(remoteAddr)
cfg, err := streamD.GetConfig(ctx)
assertNoError(ctx, err)
cfg.WriteTo(os.Stdout)
}