示例#1
0
文件: list.go 项目: bnjjj/tatcli
func usersList(skip, limit string) {
	if withGroups {
		fmt.Print(internal.GetWantReturn(fmt.Sprintf("/users?skip=%s&limit=%s&withGroups=true", skip, limit)))
	} else {
		fmt.Print(internal.GetWantReturn(fmt.Sprintf("/users?skip=%s&limit=%s", skip, limit)))
	}
}
示例#2
0
文件: list.go 项目: bnjjj/tatcli
func topicsList(skip string, limit string) {
	n := ""
	if criteriaTopic != "" {
		n += "&topic=" + criteriaTopic
	}
	if criteriaIDTopic != "" {
		n += "&idTopic=" + criteriaIDTopic
	}
	if criteriaDescription != "" {
		n += "&Description=" + criteriaDescription
	}
	if criteriaDateMinCreation != "" {
		n += "&DateMinCreation=" + criteriaDateMinCreation
	}
	if criteriaDateMaxCreation != "" {
		n += "&DateMaxCreation=" + criteriaDateMaxCreation
	}
	if criteriaGetNbMsgUnread != "" {
		n += "&getNbMsgUnread=" + criteriaGetNbMsgUnread
	}
	if criteriaGetForTatAdmin == "true" {
		n += "&getForTatAdmin=" + criteriaGetForTatAdmin
	}

	fmt.Print(internal.GetWantReturn(fmt.Sprintf("/topics?skip=%s&limit=%s%s", skip, limit, n)))
}
示例#3
0
文件: verify.go 项目: bnjjj/tatcli
func userVerify(username, tokenVerify string) {
	url := fmt.Sprintf("/user/verify/%s/%s", username, tokenVerify)
	r := internal.GetWantReturn(url)

	var verifyJSON verifyJSON
	err := json.Unmarshal([]byte(r), &verifyJSON)
	internal.Check(err)

	// Display return to user (contains clear password)
	fmt.Printf(r)

	if save && verifyJSON.Password != "" && verifyJSON.Username != "" && verifyJSON.URL != "" {
		verifyJSON.Message = ""
		jsonStr, err := json.MarshalIndent(verifyJSON, "", "  ")
		internal.Check(err)
		jsonStr = append(jsonStr, '\n')
		filename := internal.ConfigFile
		dir := path.Dir(filename)
		if _, err := os.Stat(dir); os.IsNotExist(err) {
			internal.Check(os.Mkdir(dir, 0740))
		}
		internal.Check(ioutil.WriteFile(filename, jsonStr, 0600))
	}
}
示例#4
0
文件: version.go 项目: bnjjj/tatcli
// VERSION of tatcli
const VERSION = "0.51.1"

var versionNewLine bool

func init() {
	Cmd.Flags().BoolVarP(&versionNewLine, "versionNewLine", "", true, "New line after version number. If true, display Version Engine too")
}

// Cmd version
var Cmd = &cobra.Command{
	Use:     "version",
	Short:   "Display Version of tatcli and tat engine if configured : tatcli version",
	Long:    `tatcli version`,
	Aliases: []string{"v"},
	Run: func(cmd *cobra.Command, args []string) {
		if versionNewLine {
			fmt.Printf("Version tatcli : %s\n", VERSION)
			internal.ReadConfig()
			if viper.GetString("url") == "" {
				fmt.Fprintf(os.Stderr, "Version Engine : No Engine Configured. See tatcli config --help\n")
			} else {
				fmt.Printf("Version Engine on %s : %s\n", viper.GetString("url"), internal.GetWantReturn("/version"))
			}
		} else {
			fmt.Print(VERSION)
		}
	},
}
示例#5
0
package stats

import (
	"fmt"
	"os"

	"github.com/ovh/tatcli/internal"
	"github.com/spf13/cobra"
)

var cmdStatsDBReplSetGetConfig = &cobra.Command{
	Use:   "dbReplSetGetConfig",
	Short: "DB Stats: tatcli stats dbReplSetGetConfig",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) >= 1 {
			fmt.Fprintf(os.Stderr, "Invalid argument: tatcli stats dbReplSetGetConfig --help\n")
			cmd.Usage()
		} else {
			fmt.Print(internal.GetWantReturn("/stats/db/replSetGetConfig"))
		}
	},
}
示例#6
0
package stats

import (
	"fmt"
	"os"

	"github.com/ovh/tatcli/internal"
	"github.com/spf13/cobra"
)

var cmdStatsDBSlowestQueries = &cobra.Command{
	Use:   "dbSlowestQueries",
	Short: "DB Stats slowest Queries: tatcli stats dbSlowestQueries",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) >= 1 {
			fmt.Fprintf(os.Stderr, "Invalid argument: tatcli stats dbSlowestQueriess --help\n")
			cmd.Usage()
		} else {
			fmt.Print(internal.GetWantReturn("/stats/db/slowestQueries"))
		}
	},
}
示例#7
0
文件: dump.go 项目: bnjjj/tatcli
package socket

import (
	"fmt"

	"github.com/ovh/tatcli/internal"
	"github.com/spf13/cobra"
)

var cmdSocketDump = &cobra.Command{
	Use:     "dump",
	Short:   "Dump websocket admin variables: tatcli socket dump",
	Aliases: []string{"d"},
	Run: func(cmd *cobra.Command, args []string) {
		fmt.Print(internal.GetWantReturn("/sockets/dump"))
	},
}
示例#8
0
文件: contacts.go 项目: bnjjj/tatcli
func contacts(sinceSeconds string) {
	fmt.Print(internal.GetWantReturn("/user/me/contacts/" + sinceSeconds))
}
示例#9
0
package stats

import (
	"fmt"
	"os"

	"github.com/ovh/tatcli/internal"
	"github.com/spf13/cobra"
)

var cmdStatsDBServerStatus = &cobra.Command{
	Use:   "dbServerStatus",
	Short: "DB Stats: tatcli stats dbServerStatus",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) >= 1 {
			fmt.Fprintf(os.Stderr, "Invalid argument: tatcli stats dbServerStatus --help\n")
			cmd.Usage()
		} else {
			fmt.Print(internal.GetWantReturn("/stats/db/serverStatus"))
		}
	},
}
示例#10
0
文件: list.go 项目: bnjjj/tatcli
func groupsList(skip, limit string) {
	fmt.Print(internal.GetWantReturn(fmt.Sprintf("/groups?skip=%s&limit=%s", skip, limit)))
}
示例#11
0
文件: count.go 项目: bnjjj/tatcli
package stats

import (
	"fmt"
	"os"

	"github.com/ovh/tatcli/internal"
	"github.com/spf13/cobra"
)

var cmdStatsCount = &cobra.Command{
	Use:   "count",
	Short: "Count all messages, groups, presences, users, groups, topics: tatcli stats count",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) >= 1 {
			fmt.Fprintf(os.Stderr, "Invalid argument: tatcli stats count --help\n")
			cmd.Usage()
		} else {
			fmt.Print(internal.GetWantReturn("/stats/count"))
		}
	},
}
示例#12
0
package stats

import (
	"fmt"
	"os"

	"github.com/ovh/tatcli/internal"
	"github.com/spf13/cobra"
)

var cmdStatsDBReplSetGetStatus = &cobra.Command{
	Use:   "dbReplSetGetStatus",
	Short: "DB Stats: tatcli stats dbReplSetGetStatus",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) >= 1 {
			fmt.Fprintf(os.Stderr, "Invalid argument: tatcli stats dbReplSetGetStatus --help\n")
			cmd.Usage()
		} else {
			fmt.Print(internal.GetWantReturn("/stats/db/replSetGetStatus"))
		}
	},
}
示例#13
0
文件: me.go 项目: bnjjj/tatcli
func user(path string) {
	fmt.Print(internal.GetWantReturn("/user" + path))
}
示例#14
0
package stats

import (
	"fmt"
	"os"

	"github.com/ovh/tatcli/internal"
	"github.com/spf13/cobra"
)

var cmdStatsDistribution = &cobra.Command{
	Use:   "distribution",
	Short: "Distribution of messages per topics: tatcli stats distribution",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) >= 1 {
			fmt.Fprintf(os.Stderr, "Invalid argument: tatcli stats distribution --help\n")
			cmd.Usage()
		} else {
			fmt.Print(internal.GetWantReturn("/stats/distribution"))
		}
	},
}
示例#15
0
文件: db_stats.go 项目: bnjjj/tatcli
package stats

import (
	"fmt"
	"os"

	"github.com/ovh/tatcli/internal"
	"github.com/spf13/cobra"
)

var cmdStatsDBStats = &cobra.Command{
	Use:   "dbstats",
	Short: "DB Stats: tatcli stats dbstats",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) >= 1 {
			fmt.Fprintf(os.Stderr, "Invalid argument: tatcli stats db --help\n")
			cmd.Usage()
		} else {
			fmt.Print(internal.GetWantReturn("/stats/db/stats"))
		}
	},
}
示例#16
0
文件: instance.go 项目: bnjjj/tatcli
package stats

import (
	"fmt"
	"os"

	"github.com/ovh/tatcli/internal"
	"github.com/spf13/cobra"
)

var cmdStatsInstance = &cobra.Command{
	Use:   "instance",
	Short: "Info about current instance of engine",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) >= 1 {
			fmt.Fprintf(os.Stderr, "Invalid argument: tatcli stats instance --help\n")
			cmd.Usage()
		} else {
			fmt.Print(internal.GetWantReturn("/stats/instance"))
		}
	},
}
示例#17
0
文件: list.go 项目: bnjjj/tatcli
func messagesList(topic string, skip, limit string) {
	c := ""
	if treeView != "" {
		c = c + "&treeView=" + treeView
	}
	if criteriaIDMessage != "" {
		c = c + "&idMessage=" + criteriaIDMessage
	}
	if criteriaInReplyOfID != "" {
		c = c + "&inReplyOfID=" + criteriaInReplyOfID
	}
	if criteriaInReplyOfIDRoot != "" {
		c = c + "&inReplyOfIDRoot=" + criteriaInReplyOfIDRoot
	}
	if criteriaAllIDMessage != "" {
		c = c + "&allIDMessage=" + criteriaAllIDMessage
	}
	if criteriaText != "" {
		c = c + "&text=" + criteriaText
	}
	if criteriaTopic != "" {
		c = c + "&topic=" + criteriaTopic
	}
	if criteriaLabel != "" {
		c = c + "&label=" + criteriaLabel
	}
	if criteriaNotLabel != "" {
		c = c + "&notLabel=" + criteriaNotLabel
	}
	if criteriaAndLabel != "" {
		c = c + "&andLabel=" + criteriaAndLabel
	}
	if criteriaTag != "" {
		c = c + "&tag=" + criteriaTag
	}
	if criteriaNotTag != "" {
		c = c + "&notTag=" + criteriaNotTag
	}
	if criteriaAndTag != "" {
		c = c + "&andTag=" + criteriaAndTag
	}
	if criteriaDateMinCreation != "" {
		c = c + "&dateMinCreation=" + criteriaDateMinCreation
	}
	if criteriaDateMaxCreation != "" {
		c = c + "&dateMaxCreation=" + criteriaDateMaxCreation
	}
	if criteriaDateMinUpdate != "" {
		c = c + "&dateMinUpdate=" + criteriaDateMinUpdate
	}
	if criteriaDateMaxUpdate != "" {
		c = c + "&dateMaxUpdate=" + criteriaDateMaxUpdate
	}
	if criteriaUsername != "" {
		c = c + "&username="******"" {
		c = c + "&limitMinNbReplies=" + criteriaLimitMinNbReplies
	}
	if criteriaLimitMaxNbReplies != "" {
		c = c + "&limitMaxNbReplies=" + criteriaLimitMaxNbReplies
	}
	fmt.Print(internal.GetWantReturn(fmt.Sprintf("/messages%s?skip=%s&limit=%s%s", topic, skip, limit, c)))
}