mirror of
https://github.com/mainflux/mainflux.git
synced 2025-04-27 13:48:49 +08:00

* Use per-service URL in SDK Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com> * Fix CLI Signed-off-by: Drasko Draskovic <drasko.draskovic@gmail.com> * Fix CLI messaging Signed-off-by: Drasko Draskovic <drasko.draskovic@gmail.com> * Fix message tests Signed-off-by: Drasko Draskovic <drasko.draskovic@gmail.com> * Simplify Bootstrap Signed-off-by: Drasko Draskovic <drasko.draskovic@gmail.com> * Update API doc and responses Signed-off-by: Drasko Draskovic <drasko.draskovic@gmail.com> * fix failing certs, bootstrap tests Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * fix failing certs, bootstrap tests Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * Fix tests and rename to auth service Signed-off-by: Drasko Draskovic <drasko.draskovic@gmail.com> * Clean the code Signed-off-by: Drasko Draskovic <drasko.draskovic@gmail.com> * Remove unnecessary Repository logs Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Always return error in case of repo failure Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Cleanup SDK and CLI Update tests, remove linter warnings, remove dead code. Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Clean the code Signed-off-by: Drasko Draskovic <drasko.draskovic@gmail.com> * Undo Bootstrap changes Signed-off-by: Drasko Draskovic <drasko.draskovic@gmail.com> * Fix tests Signed-off-by: Drasko Draskovic <drasko.draskovic@gmail.com> * Fix linter Signed-off-by: Drasko Draskovic <drasko.draskovic@gmail.com> Co-authored-by: mteodor <mirko.teodorovic@gmail.com> Co-authored-by: dusanb94 <dusan.borovcanin@mainflux.com>
65 lines
1.3 KiB
Go
65 lines
1.3 KiB
Go
// Copyright (c) Mainflux
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package cli
|
|
|
|
import "github.com/spf13/cobra"
|
|
|
|
var cmdMessages = []cobra.Command{
|
|
{
|
|
Use: "send",
|
|
Short: "send <channel_id>[.<subtopic>...] <JSON_string> <thing_key>",
|
|
Long: `Sends message on the channel`,
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
if len(args) != 3 {
|
|
logUsage(cmd.Short)
|
|
return
|
|
}
|
|
|
|
if err := sdk.SendMessage(args[0], args[1], args[2]); err != nil {
|
|
logError(err)
|
|
return
|
|
}
|
|
|
|
logOK()
|
|
},
|
|
},
|
|
{
|
|
Use: "read",
|
|
Short: "read <channel_id>[.<subtopic>...] <thing_key>",
|
|
Long: `Reads all channel messages`,
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
if len(args) != 2 {
|
|
logUsage(cmd.Short)
|
|
return
|
|
}
|
|
|
|
m, err := sdk.ReadMessages(args[0], args[1])
|
|
if err != nil {
|
|
logError(err)
|
|
return
|
|
}
|
|
|
|
logJSON(m)
|
|
},
|
|
},
|
|
}
|
|
|
|
// NewMessagesCmd returns messages command.
|
|
func NewMessagesCmd() *cobra.Command {
|
|
cmd := cobra.Command{
|
|
Use: "messages",
|
|
Short: "Send or read messages",
|
|
Long: `Send or read messages using the http-adapter and the configured database reader`,
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
logUsage("messages [send | read]")
|
|
},
|
|
}
|
|
|
|
for i := range cmdMessages {
|
|
cmd.AddCommand(&cmdMessages[i])
|
|
}
|
|
|
|
return &cmd
|
|
}
|