/
secrets.go
61 lines (49 loc) · 1.08 KB
/
secrets.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Code generated. DO NOT EDIT.
package main
import (
"bytes"
"context"
"fmt"
"os"
"github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto"
"github.com/spf13/cobra"
)
var Verbose, OutputJSON bool
var ctx = context.Background()
var marshaler = &jsonpb.Marshaler{Indent: " "}
func init() {
rootCmd.PersistentFlags().BoolVarP(&Verbose, "verbose", "v", false, "Print verbose output")
rootCmd.PersistentFlags().BoolVarP(&OutputJSON, "json", "j", false, "Print JSON output")
}
var rootCmd = &cobra.Command{
Use: "secrets",
Short: "Root command of secrets",
}
func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
func main() {
Execute()
}
func printVerboseInput(srv, mthd string, data interface{}) {
fmt.Println("Service:", srv)
fmt.Println("Method:", mthd)
fmt.Print("Input: ")
printMessage(data)
}
func printMessage(data interface{}) {
var s string
if msg, ok := data.(proto.Message); ok {
s = msg.String()
if OutputJSON {
var b bytes.Buffer
marshaler.Marshal(&b, msg)
s = b.String()
}
}
fmt.Println(s)
}