예제 #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)))
}