-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathroot.go
More file actions
51 lines (39 loc) · 1.24 KB
/
root.go
File metadata and controls
51 lines (39 loc) · 1.24 KB
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
package root
import (
"os"
"github.com/MakeNowJust/heredoc"
"github.com/spf13/cobra"
"github.com/GetStream/stream-cli/pkg/cmd/chat"
cfgCmd "github.com/GetStream/stream-cli/pkg/cmd/config"
feedsCmd "github.com/GetStream/stream-cli/pkg/cmd/feeds"
"github.com/GetStream/stream-cli/pkg/config"
"github.com/GetStream/stream-cli/pkg/version"
)
var cfgPath = new(string)
func NewCmd() *cobra.Command {
root := &cobra.Command{
Use: "stream-cli <command> <subcommand> [flags]",
Short: "Stream CLI",
Long: "Interact with your Stream applications easily",
Example: heredoc.Doc(`
# Get Chat application settings
$ stream-cli chat get-app
# List all Chat channel types
$ stream-cli chat list-channel-types
# Create a new Chat user
$ stream-cli chat upsert-user --properties "{\"id\":\"my-user-1\"}"
`),
Version: version.FmtVersion(),
}
fl := root.PersistentFlags()
fl.String("app", "", "[optional] Application name to use as it's defined in the configuration file")
fl.StringVar(cfgPath, "config", "", "[optional] Explicit config file path")
root.AddCommand(
cfgCmd.NewRootCmd(),
chat.NewRootCmd(),
feedsCmd.NewRootCmd(),
)
cobra.OnInitialize(config.GetInitConfig(root, cfgPath))
root.SetOut(os.Stdout)
return root
}