()
| 16 | var cfgPath = new(string) |
| 17 | |
| 18 | func NewCmd() *cobra.Command { |
| 19 | root := &cobra.Command{ |
| 20 | Use: "stream-cli <command> <subcommand> [flags]", |
| 21 | Short: "Stream CLI", |
| 22 | Long: "Interact with your Stream applications easily", |
| 23 | Example: heredoc.Doc(` |
| 24 | # Get Chat application settings |
| 25 | $ stream-cli chat get-app |
| 26 | |
| 27 | # List all Chat channel types |
| 28 | $ stream-cli chat list-channel-types |
| 29 | |
| 30 | # Create a new Chat user |
| 31 | $ stream-cli chat upsert-user --properties "{\"id\":\"my-user-1\"}" |
| 32 | |
| 33 | # Upload a chat import |
| 34 | $ stream-cli import chat upload-import data.json --mode insert |
| 35 | |
| 36 | # Upload a feeds import |
| 37 | $ stream-cli import feeds upload-import data.json |
| 38 | `), |
| 39 | Version: version.FmtVersion(), |
| 40 | } |
| 41 | |
| 42 | fl := root.PersistentFlags() |
| 43 | fl.String("app", "", "[optional] Application name to use as it's defined in the configuration file") |
| 44 | fl.StringVar(cfgPath, "config", "", "[optional] Explicit config file path") |
| 45 | |
| 46 | root.AddCommand( |
| 47 | cfgCmd.NewRootCmd(), |
| 48 | chat.NewRootCmd(), |
| 49 | importcmd.NewRootCmd(), |
| 50 | ) |
| 51 | |
| 52 | cobra.OnInitialize(config.GetInitConfig(root, cfgPath)) |
| 53 | |
| 54 | root.SetOut(os.Stdout) |
| 55 | |
| 56 | return root |
| 57 | } |
no test coverage detected