Initial commit, pt. 42

This commit is contained in:
Dmitrii Okunev
2024-07-14 22:40:24 +01:00
parent 8476cbc7f1
commit 60013622d4
45 changed files with 6593 additions and 613 deletions

View File

@@ -3,6 +3,7 @@ package commands
import (
"bytes"
"context"
"crypto"
"encoding/json"
"fmt"
"io"
@@ -62,6 +63,12 @@ var (
Run: variablesGet,
}
VariablesGetHash = &cobra.Command{
Use: "get_hash",
Args: cobra.ExactArgs(1),
Run: variablesGetHash,
}
VariablesSet = &cobra.Command{
Use: "set",
Args: cobra.ExactArgs(1),
@@ -78,6 +85,7 @@ func init() {
Root.AddCommand(Variables)
Variables.AddCommand(VariablesGet)
Variables.AddCommand(VariablesGetHash)
Variables.AddCommand(VariablesSet)
Root.PersistentFlags().Var(&LoggerLevel, "log-level", "")
@@ -176,6 +184,20 @@ func variablesGet(cmd *cobra.Command, args []string) {
assertNoError(ctx, err)
}
func variablesGetHash(cmd *cobra.Command, args []string) {
variableKey := args[0]
ctx := cmd.Context()
remoteAddr, err := cmd.Flags().GetString("remote-addr")
assertNoError(ctx, err)
streamD := client.New(remoteAddr)
b, err := streamD.GetVariableHash(ctx, consts.VarKey(variableKey), crypto.SHA1)
assertNoError(ctx, err)
fmt.Printf("%X\n", b)
}
func variablesSet(cmd *cobra.Command, args []string) {
variableKey := args[0]
ctx := cmd.Context()