示例#1
0
文件: truncate.go 项目: ovh/tatcli
func topicTruncate(topic string) {
	j := tat.TopicNameJSON{Topic: topic}
	if force {
		out, err := internal.Client().TopicTruncate(j)
		internal.Check(err)
		if internal.Verbose {
			internal.Print(out)
		}
	} else {
		fmt.Print("Are you really sure ? You will delete all messages even if a user has a message in his tasks. Please enter again topic name to confirm: ")
		var confirmTopic string
		fmt.Scanln(&confirmTopic)

		if confirmTopic == topic {
			fmt.Printf("Please enter 'yes' to confirm removing all messages from %s: ", topic)
			var confirmYes string
			fmt.Scanln(&confirmYes)
			if confirmYes == "yes" {
				out, err := internal.Client().TopicTruncate(j)
				internal.Check(err)
				internal.Print(out)
				return
			}
		} else {
			fmt.Printf("Error. You enter %s instead of %s\n", confirmTopic, topic)
		}
		fmt.Println("Nothing done")
	}
}
示例#2
0
文件: send.go 项目: ovh/tatcli
func (ui *tatui) sendSimpleActionMsg() {
	t := strings.TrimSpace(ui.send.Text[1:])

	var err error
	var msg *tat.MessageJSONOut
	switch t {
	case "voteup":
		msg, err = internal.Client().MessageVoteUP(ui.currentTopic.Topic, ui.currentListMessages[ui.selectedPaneMessages][ui.uilists[uiMessages][ui.selectedPaneMessages].position].ID)
	case "votedown":
		msg, err = internal.Client().MessageVoteDown(ui.currentTopic.Topic, ui.currentListMessages[ui.selectedPaneMessages][ui.uilists[uiMessages][ui.selectedPaneMessages].position].ID)
	case "unvoteup":
		msg, err = internal.Client().MessageUnVoteUP(ui.currentTopic.Topic, ui.currentListMessages[ui.selectedPaneMessages][ui.uilists[uiMessages][ui.selectedPaneMessages].position].ID)
	case "unvotedown":
		msg, err = internal.Client().MessageUnVoteDown(ui.currentTopic.Topic, ui.currentListMessages[ui.selectedPaneMessages][ui.uilists[uiMessages][ui.selectedPaneMessages].position].ID)
	case "like":
		msg, err = internal.Client().MessageLike(ui.currentTopic.Topic, ui.currentListMessages[ui.selectedPaneMessages][ui.uilists[uiMessages][ui.selectedPaneMessages].position].ID)
	case "unlike":
		msg, err = internal.Client().MessageUnlike(ui.currentTopic.Topic, ui.currentListMessages[ui.selectedPaneMessages][ui.uilists[uiMessages][ui.selectedPaneMessages].position].ID)
	case "task":
		msg, err = internal.Client().MessageTask(ui.currentTopic.Topic, ui.currentListMessages[ui.selectedPaneMessages][ui.uilists[uiMessages][ui.selectedPaneMessages].position].ID)
	case "untask":
		msg, err = internal.Client().MessageUntask(ui.currentTopic.Topic, ui.currentListMessages[ui.selectedPaneMessages][ui.uilists[uiMessages][ui.selectedPaneMessages].position].ID)
	}

	if err != nil {
		ui.msg.Text = err.Error()
	} else {
		ui.uilists[uiMessages][ui.selectedPaneMessages].list.Items[ui.uilists[uiMessages][ui.selectedPaneMessages].position] = ui.formatMessage(msg.Message, true)
		ui.addMarker(ui.uilists[uiMessages][ui.selectedPaneMessages], ui.selectedPaneMessages)
	}
	if msg.Info != "" {
		ui.msg.Text = msg.Info
	}
}
示例#3
0
文件: topics.go 项目: ovh/tatcli
func (ui *tatui) updateTopics() {
	start := time.Now().UnixNano()
	nbPerPage := ui.getNbPerPage()

	c := ui.currentFilterTopics
	if c == nil {
		c = &tat.TopicCriteria{}
	}
	if ui.onlyUnread {
		c.Skip = 0
		c.Limit = 1000
	} else {
		c.Skip = ui.uilists[uiTopics][0].page * nbPerPage
		c.Limit = nbPerPage
	}

	c.OnlyFavorites = ui.onlyFavorites
	c.GetNbMsgUnread = "true"

	topicsJSON, err := internal.Client().TopicList(c)
	if err != nil {
		ui.msg.Text = err.Error()
		return
	}
	var strs []string
	topics := []tat.Topic{}
	ui.currentListUnreadTopics = topicsJSON.TopicsMsgUnread
	privateTasksTopic := fmt.Sprintf("/Private/%s/Tasks", viper.GetString("username"))
	for _, topic := range topicsJSON.Topics {
		if topic.Topic == privateTasksTopic {
			continue
		}

		topicLine, isUnread := ui.formatTopic(topic, true)
		if !ui.onlyUnread || isUnread {
			strs = append(strs, topicLine)
			topics = append(topics, topic)
		}
	}
	if ui.onlyUnread {
		max := nbPerPage - 1
		if len(topics) < nbPerPage {
			max = len(topics) - 1
		}
		if ui.uilists[uiTopics][0].page*nbPerPage > len(topics) {
			return
		}
		ui.currentListTopic = topics[ui.uilists[uiTopics][0].page*nbPerPage : max]
		ui.uilists[uiTopics][0].list.Items = strs[ui.uilists[uiTopics][0].page*nbPerPage : max]
	} else {
		ui.currentListTopic = topics
		ui.uilists[uiTopics][0].list.Items = strs
	}

	ui.msg.Text = ""
	ui.addMarker(ui.uilists[uiTopics][0], 0)
	delta := int64((time.Now().UnixNano() - start) / 1000000)
	ui.lastRefresh.Text = fmt.Sprintf("%s (%dms)", time.Now().Format(time.Stamp), delta)
	ui.render()
}
示例#4
0
文件: send.go 项目: ovh/tatcli
func (ui *tatui) sendMsg() {
	if ui.current != uiMessage && ui.current != uiMessages {
		return
	}
	if len(strings.TrimSpace(ui.send.Text)) == 0 {
		return
	}
	var err error
	var msg *tat.MessageJSONOut
	switch ui.current {
	case uiMessages:
		msg, err = message.Create(ui.currentTopic.Topic, ui.send.Text)
	case uiMessage:
		msg, err = internal.Client().MessageReply(ui.currentTopic.Topic, ui.currentMessage.ID, ui.send.Text)
	}
	if err != nil {
		ui.msg.Text = err.Error()
		return
	}
	if msg.Info != "" {
		ui.msg.Text = msg.Info
	}
	ui.send.Text = ""
	ui.render()
	ui.updateMessages()
}
示例#5
0
文件: messages.go 项目: ovh/tatcli
func (ui *tatui) updateMessagesPane(pane int, criteria *tat.MessageCriteria) {

	// check if ui.uilists[uiMessages] has changed
	if pane >= len(ui.uilists[uiMessages]) {
		return
	}

	messagesJSON, err := internal.Client().MessageList(criteria.Topic, criteria)
	if err != nil {
		ui.msg.Text = err.Error()
		return
	}
	var strs []string
	for _, msg := range messagesJSON.Messages {
		strs = append(strs, ui.formatMessage(msg, true))
	}

	ui.uilists[uiMessages][pane].list.Items = strs
	ui.currentListMessages[pane] = messagesJSON.Messages
	ui.msg.Text = ""
	if ui.selectedPaneMessages == pane {
		ui.addMarker(ui.uilists[uiMessages][pane], pane)
	}
	ui.render()
}
示例#6
0
文件: message.go 项目: ovh/tatcli
func (ui *tatui) updateMessage() {
	start := time.Now().UnixNano()

	c := &tat.MessageCriteria{
		IDMessage: ui.currentMessage.ID,
		Topic:     ui.currentTopic.Topic,
		TreeView:  "onetree",
	}
	messagesJSON, err := internal.Client().MessageList(ui.currentTopic.Topic, c)
	if err != nil {
		ui.msg.Text = err.Error()
		ui.render()
		return
	}

	thread := []string{}
	for _, msg := range messagesJSON.Messages {
		thread = ui.addMessage(msg, 0)
	}

	ui.uilists[uiMessage][0].list.Items = thread
	ui.uilists[uiMessage][0].list.BorderLabel = " View Message, Ctrl+b to return back "
	delta := int64((time.Now().UnixNano() - start) / 1000000)
	ui.lastRefresh.Text = fmt.Sprintf("%s (%dms)", time.Now().Format(time.Stamp), delta)
	ui.msg.Text = ""
}
示例#7
0
文件: messages.go 项目: ovh/tatcli
func (ui *tatui) removeLabel(msg tat.Message, label string) error {
	var err error
	if label == "doing" && msg.ContainsLabel("doing") {
		internal.Client().MessageUntask(msg.Topic, msg.ID)
	} else {
		internal.Client().MessageUnlabel(msg.Topic, msg.ID, label)
		if label == "done" {
			for _, l := range msg.Labels {
				if strings.HasPrefix(l.Text, "done:") {
					internal.Client().MessageUnlabel(msg.Topic, msg.ID, l.Text)
				}
			}
		}
	}
	return err
}
示例#8
0
文件: messages.go 项目: ovh/tatcli
func (ui *tatui) monitoringActionOnMessage() {

	if _, ok := ui.uilists[uiMessages][ui.selectedPaneMessages]; !ok {
		return
	}
	if ui.uilists[uiMessages][ui.selectedPaneMessages].position >= len(ui.currentListMessages[ui.selectedPaneMessages]) {
		return
	}
	msg := ui.currentListMessages[ui.selectedPaneMessages][ui.uilists[uiMessages][ui.selectedPaneMessages].position]
	var erradd, errdel error

	// #d04437 red open
	// #14892c green done
	// #5484ed blue doing

	// TODO use relabel

	if msg.ContainsLabel("AL") {
		// set to doing
		if !msg.ContainsLabel("UP") {
			_, erradd = internal.Client().MessageLabel(msg.Topic, msg.ID, tat.Label{Text: "UP", Color: hexColorGreen})
		}
		_, errdel = internal.Client().MessageUnlabel(msg.Topic, msg.ID, "AL")
	} else {
		// set to AL
		if !msg.ContainsLabel("AL") {
			_, erradd = internal.Client().MessageLabel(msg.Topic, msg.ID, tat.Label{Text: "AL", Color: hexColorRed})
		}
		if msg.ContainsLabel("UP") {
			_, errdel = internal.Client().MessageUnlabel(msg.Topic, msg.ID, "UP")
		}
	}

	ui.msg.Text = ""
	if erradd != nil {
		ui.msg.Text += "add:" + erradd.Error()
	}
	if errdel != nil {
		ui.msg.Text += " del:" + errdel.Error()
		return
	}
	msg.Text = "please wait, updating message..."
	ui.render()
	ui.updateMessages()
}
示例#9
0
func topicAddParameter(topic string, parameters []string) {
	for _, param := range parameters {
		parameterSplitted := strings.Split(param, ":")
		if len(parameterSplitted) != 2 {
			continue
		}
		_, err := internal.Client().TopicAddParameter(topic, parameterSplitted[0], parameterSplitted[1], recursive)
		internal.Check(err)
	}
}
示例#10
0
文件: send.go 项目: ovh/tatcli
func (ui *tatui) showVersion() {
	ui.msg.Text = ""
	//body, err := internal.Request("GET", http.StatusOK, "/version", nil)
	body, err := internal.Client().Version()
	if err != nil {
		ui.msg.Text = err.Error()
		return
	}
	ui.showResult("tatcli version -> GET on "+viper.GetString("url")+"/version ", string(body))
	ui.msg.Text = "Tatcli:" + internal.VERSION
}
示例#11
0
文件: send.go 项目: ovh/tatcli
func (ui *tatui) sendUnlabel() {
	if len(strings.TrimSpace(ui.send.Text)) == 0 {
		return
	}

	// "/unlabel " : 8 char
	labelToRemove := strings.TrimSpace(ui.send.Text[8:])
	msg, err := internal.Client().MessageUnlabel(ui.currentTopic.Topic, ui.currentListMessages[ui.selectedPaneMessages][ui.uilists[uiMessages][ui.selectedPaneMessages].position].ID, labelToRemove)
	if err != nil {
		ui.msg.Text = err.Error()
	}
	if msg.Info != "" {
		ui.msg.Text = msg.Info
	}
}
示例#12
0
文件: add.go 项目: ovh/tatcli
// Create creates a message in specified topic
func Create(topic, message string) (*tat.MessageJSONOut, error) {
	m := tat.MessageJSON{Text: message, Topic: topic}
	if dateCreation > 0 {
		m.DateCreation = float64(dateCreation)
	}
	for _, label := range cmdLabel {
		s := strings.Split(label, ";")
		if len(s) == 2 {
			m.Labels = append(m.Labels, tat.Label{Text: s[1], Color: s[0]})
		} else {
			return nil, fmt.Errorf("Invalid argument label %s to add a message: tatcli msg add --help\n", label)
		}
	}

	return internal.Client().MessageAdd(m)
}
示例#13
0
文件: send.go 项目: ovh/tatcli
func (ui *tatui) showMe() {
	ui.msg.Text = ""
	//body, err := internal.Request("GET", http.StatusOK, "/user/me", nil)
	body, err := internal.Client().UserMe()
	if err != nil {
		ui.msg.Text = err.Error()
		return
	}

	out, err := tat.Sprint(body)
	if err != nil {
		ui.msg.Text = err.Error()
		return
	}

	ui.showResult("tatcli user me -> GET on /user/me ", string(out))
}
示例#14
0
文件: ui.go 项目: ovh/tatcli
// loadArgs load args form command line and return topic, filter, command
func (ui *tatui) loadArgs(args []string) []string {
	// example :
	// /YourTopic/SubTopic /split label:open label:doing label:done /save
	// /YourTopic/SubTopic /run CD
	// /YourTopic/SubTopic /run CD /save
	// /YourTopic/SubTopic /monitoring /save
	if len(args) < 1 {
		return []string{}
	}

	topicName := ""
	if strings.HasPrefix(args[0], "/") {
		topicName = args[0]
	}
	c := &tat.TopicCriteria{Topic: strings.TrimSpace(topicName)}

	//topicsB, err := internal.Request("GET", 200, topic.TopicsListURL(c), nil)
	topicsJSON, err := internal.Client().TopicList(c)
	if err != nil {
		internal.Exit("Error while loading topic %s error:%s", args[0], err.Error())
	}

	if len(topicsJSON.Topics) != 1 {
		internal.Exit("Args on tatcli ui should begin with topic name. Please check it on %s", args[0])
	}

	ui.currentTopic = topicsJSON.Topics[0]

	commands := []string{}
	cmd := ""
	for i := 1; i < len(args); i++ {
		if strings.HasPrefix(args[i], "/") {
			if cmd != "" {
				commands = append(commands, cmd)
			}
			cmd = args[i]
		} else {
			cmd += " " + args[i]
		}
	}
	if cmd != "" {
		commands = append(commands, cmd)
	}
	return commands
}
示例#15
0
文件: verify.go 项目: ovh/tatcli
func userVerify(username, tokenVerify string) {
	verifyJSON, err := internal.Client().UserVerify(username, tokenVerify)
	internal.Check(err)

	// Display return to user (contains clear password)
	internal.Print(verifyJSON)

	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))
	}
}
示例#16
0
文件: send.go 项目: ovh/tatcli
func (ui *tatui) sendLabel() {
	if len(strings.TrimSpace(ui.send.Text)) == 0 {
		return
	}

	// "/label " : 6 char
	t := ui.send.Text[6:]
	// /label ###### text
	color := t[0:strings.Index(t, " ")]
	text := t[strings.Index(t, " ")+1:]

	//msg, err := message.Action("label", ui.currentTopic.Topic, ui.currentListMessages[ui.selectedPaneMessages][ui.uilists[uiMessages][ui.selectedPaneMessages].position].ID, text, color)
	msg, err := internal.Client().MessageLabel(ui.currentTopic.Topic, ui.currentListMessages[ui.selectedPaneMessages][ui.uilists[uiMessages][ui.selectedPaneMessages].position].ID, tat.Label{Text: text, Color: color})
	if err != nil {
		ui.msg.Text = err.Error()
	}
	if msg.Info != "" {
		ui.msg.Text = msg.Info
	}
}
示例#17
0
文件: set_admin.go 项目: ovh/tatcli
package user

import (
	"github.com/ovh/tat"
	"github.com/ovh/tatcli/internal"
	"github.com/spf13/cobra"
)

var cmdUserSetAdmin = &cobra.Command{
	Use:   "setAdmin",
	Short: "Grant user to Tat admin (admin only): tatcli user setAdmin <username>",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) == 1 {
			out, err := internal.Client().UserSetAdmin(tat.UsernameUserJSON{
				Username: args[0],
			})
			internal.Check(err)
			internal.Print(out)
		} else {
			internal.Exit("Invalid argument: tatcli user setAdmin --help\n")
		}
	},
}
示例#18
0
文件: messages.go 项目: ovh/tatcli
func (ui *tatui) runActionOnMessage(reverse bool) {
	if _, ok := ui.uilists[uiMessages][ui.selectedPaneMessages]; !ok {
		return
	}
	if ui.uilists[uiMessages][ui.selectedPaneMessages].position >= len(ui.currentListMessages[ui.selectedPaneMessages]) {
		return
	}
	msg := ui.currentListMessages[ui.selectedPaneMessages][ui.uilists[uiMessages][ui.selectedPaneMessages].position]
	var erradd, erradd2, errdel, errdel2 error

	// #d04437 red open
	// #14892c green done
	// #5484ed blue doing

	action := "notdefined"

	if (msg.ContainsLabel("open") && !reverse) ||
		(msg.ContainsLabel("done") && reverse) { // set to doing
		errdel = ui.removeLabel(msg, "open")
		errdel2 = ui.removeLabel(msg, "done")
		if !msg.ContainsLabel("doing") {
			//_, erradd = message.Action("task", "/", msg.ID, "", "")
			_, erradd = internal.Client().MessageTask(msg.Topic, msg.ID)
		}
		action = "doing"
	} else if (msg.ContainsLabel("doing") && !reverse) ||
		(msg.ContainsLabel("open") && reverse) { // set to done
		errdel = ui.removeLabel(msg, "doing")
		errdel2 = ui.removeLabel(msg, "open")
		if !msg.ContainsLabel("done") {
			//_, erradd = message.Action("label", "/", msg.ID, "done", hexColorGreen)
			_, erradd = internal.Client().MessageLabel(msg.Topic, msg.ID, tat.Label{Text: "done", Color: hexColorGreen})
		}
		action = "done"
	} else if (msg.ContainsLabel("done") && !reverse) ||
		(msg.ContainsLabel("doing") && reverse) { // set to open
		errdel = ui.removeLabel(msg, "done")
		errdel2 = ui.removeLabel(msg, "doing")
		if !msg.ContainsLabel("open") {
			//_, erradd = message.Action("label", "/", msg.ID, "open", hexColorRed)
			_, erradd = internal.Client().MessageLabel(msg.Topic, msg.ID, tat.Label{Text: "open", Color: hexColorRed})
		}
		action = "open"
	} else {
		_, erradd = internal.Client().MessageTask(msg.Topic, msg.ID)
		action = "doing"
	}

	ui.msg.Text = ""
	if erradd != nil {
		ui.msg.Text += "add:" + erradd.Error()
	}
	if erradd2 != nil {
		ui.msg.Text += "add:" + erradd2.Error()
	}
	if errdel != nil {
		ui.msg.Text += " del:" + errdel.Error()
		return
	}
	if errdel2 != nil {
		ui.msg.Text += " del:" + errdel2.Error()
		return
	}
	ui.postHookRunActionOnMessage(action, msg)
	msg.Text = "please wait, updating message..."
	ui.render()
	ui.updateMessages()
}
示例#19
0
文件: create.go 项目: ovh/tatcli
package topic

import (
	"strings"

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

var cmdTopicCreate = &cobra.Command{
	Use:   "create",
	Short: "Create a new topic: tatcli create <topic> <description of topic>",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) >= 2 {
			description := strings.Join(args[1:], " ")
			topic, err := internal.Client().TopicCreate(tat.TopicCreateJSON{
				Topic:       args[0],
				Description: description,
			})
			internal.Check(err)
			if internal.Verbose {
				internal.Print(topic)
			}
		} else {
			internal.Exit("Invalid argument: tatcli topic create --help\n")
		}
	},
}
示例#20
0
package topic

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

func init() {
	cmdTopicDeleteParameter.Flags().BoolVarP(&recursive, "recursive", "r", false, "Remove Parameter recursively")
}

var cmdTopicDeleteParameter = &cobra.Command{
	Use:   "deleteParameter",
	Short: "Remove Parameter to a topic: tatcli topic deleteParameter [--recursive] <topic> <key> [<key2>]... ",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) >= 2 {
			err := internal.Client().TopicDeleteParameters(args[0], args[1:], recursive)
			internal.Check(err)
		} else {
			internal.Exit("Invalid argument: tatcli topic deleteParameter --help\n")
		}
	},
}
示例#21
0
package topic

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

func init() {
	cmdTopicDeleteAdminGroup.Flags().BoolVarP(&recursive, "recursive", "r", false, "Apply Delete Rights Admin recursively")
}

var cmdTopicDeleteAdminGroup = &cobra.Command{
	Use:   "deleteAdminGroup",
	Short: "Delete Admin Groups from a topic: tatcli topic deleteAdminGroup [--recursive] <topic> <groupname1> [<groupname2>]...",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) >= 2 {
			err := internal.Client().TopicDeleteAdminGroups(args[0], args[1:], recursive)
			internal.Check(err)
		} else {
			internal.Exit("Invalid argument: tatcli topic deleteAdminGroup --help\n")
		}
	},
}
示例#22
0
文件: list.go 项目: ovh/tatcli
)

var (
	criteria tat.TopicCriteria
)

func init() {
	cmdTopicList.Flags().StringVarP(&criteria.Topic, "topic", "", "", "Search by Topic name, example: /topicA")
	cmdTopicList.Flags().StringVarP(&criteria.TopicPath, "topicPath", "", "", "Search by Topic Path, example: /topicA will return /topicA/subA, /topicA/subB")
	cmdTopicList.Flags().StringVarP(&criteria.IDTopic, "idTopic", "", "", "Search by id of topic")
	cmdTopicList.Flags().StringVarP(&criteria.Description, "description", "", "", "Search by description of topic")
	cmdTopicList.Flags().StringVarP(&criteria.DateMinCreation, "dateMinCreation", "", "", "Filter result on dateCreation, timestamp Unix format")
	cmdTopicList.Flags().StringVarP(&criteria.DateMaxCreation, "dateMaxCreation", "", "", "Filter result on dateCreation, timestamp Unix Format")
	cmdTopicList.Flags().StringVarP(&criteria.GetNbMsgUnread, "getNbMsgUnread", "", "", "If true, add new array to return, topicsMsgUnread with topic:nbUnreadMsgSinceLastPresenceOnTopic")
	cmdTopicList.Flags().StringVarP(&criteria.OnlyFavorites, "getOnlyFavorites", "", "", "If true, returns only favorites topics, except /Private/* (all /Private/* are returned)")
	cmdTopicList.Flags().StringVarP(&criteria.GetForTatAdmin, "getForTatAdmin", "", "", "(AdminOnly) If true, and requester is a Tat Admin, returns all topics (except /Private/*) without checking user / group access (RO or RW on Topic)")
}

var cmdTopicList = &cobra.Command{
	Use:     "list",
	Short:   "List all topics: tatcli topic list [<skip>] [<limit>], tatcli topic list -h for see all criterias",
	Aliases: []string{"l"},
	Run: func(cmd *cobra.Command, args []string) {
		criteria.Skip, criteria.Limit = internal.GetSkipLimit(args)
		c := internal.Client()
		out, err := c.TopicList(&criteria)
		internal.Check(err)
		internal.Print(out)
	},
}
示例#23
0
package topic

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

var cmdTopicAllComputeTags = &cobra.Command{
	Use:   "allcomputetags",
	Short: "Compute Tags on all topics, only for tat admin : tatcli topic allcomputetags",
	Run: func(cmd *cobra.Command, args []string) {
		out, err := internal.Client().TopicAllComputeTags()
		internal.Check(err)
		if internal.Verbose {
			internal.Print(out)
		}
	},
}
示例#24
0
package topic

import (
	"github.com/ovh/tat"
	"github.com/ovh/tatcli/internal"
	"github.com/spf13/cobra"
)

var cmdTopicComputeTags = &cobra.Command{
	Use:   "computetags",
	Short: "Compute Tags on this topic, only for tat admin and administrators on topic : tatcli topic computetags <topic>",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) == 1 {
			out, err := internal.Client().TopicComputeTags(tat.TopicNameJSON{Topic: args[0]})
			internal.Check(err)
			if internal.Verbose {
				internal.Print(out)
			}
		} else {
			internal.Exit("Invalid argument: tatcli topic computetags --help\n")
		}
	},
}
示例#25
0
文件: add.go 项目: ovh/tatcli
package user

import (
	"strings"

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

var cmdUserAdd = &cobra.Command{
	Use:   "add",
	Short: "Add a user: tatcli user add <username> <email> <fullname>",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) >= 3 {
			out, err := internal.Client().UserAdd(tat.UserCreateJSON{
				Username: args[0],
				Fullname: strings.Join(args[2:], " "),
				Email:    args[1],
				Callback: "tatcli --url=:scheme://:host::port:path user verify --save :username :token",
			})
			internal.Check(err)
			internal.Print(out)
		} else {
			internal.Exit("Invalid argument to add user: tatcli user add --help\n")
		}
	},
}
示例#26
0
package user

import (
	"github.com/ovh/tat"
	"github.com/ovh/tatcli/internal"
	"github.com/spf13/cobra"
)

var cmdUserResetSystem = &cobra.Command{
	Use:   "resetSystemUser",
	Short: "Reset password for a system user (admin only): tatcli user resetSystemUser <username>",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) == 1 {
			out, err := internal.Client().UserResetSystem(tat.UsernameUserJSON{
				Username: args[0],
			})
			internal.Check(err)
			internal.Print(out)
		} else {
			internal.Exit("Invalid argument: tatcli user resetSystemUser --help\n")
		}
	},
}
示例#27
0
文件: votedown.go 项目: ovh/tatcli
package message

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

var cmdMessageVoteDown = &cobra.Command{
	Use:   "votedown",
	Short: "Vote Down a message: tatcli message votedown <topic> <idMessage>",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) == 1 {
			out, err := internal.Client().MessageVoteDown(args[0], args[1])
			internal.Check(err)
			if internal.Verbose {
				internal.Print(out)
			}
		} else {
			internal.Exit("Invalid argument to votedown a message: tatcli message votedown --help\n")
		}
	},
}
示例#28
0
package stats

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

var cmdStatsDBCollections = &cobra.Command{
	Use:   "dbCollections",
	Short: "DB Stats on each collection: tatcli stats dbCollections",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) >= 1 {
			internal.Exit("Invalid argument: tatcli stats dbCollections --help\n")
			cmd.Usage()
		} else {
			out, err := internal.Client().StatsDBCollections()
			internal.Check(err)
			internal.Print(out)
		}
	},
}
示例#29
0
文件: parameter.go 项目: ovh/tatcli
			Topic: args[0],
		}

		p.MaxLength, err = strconv.Atoi(args[1])
		internal.Check(err)
		p.CanForceDate, err = strconv.ParseBool(args[2])
		internal.Check(err)
		p.CanUpdateMsg, err = strconv.ParseBool(args[3])
		internal.Check(err)
		p.CanDeleteMsg, err = strconv.ParseBool(args[4])
		internal.Check(err)
		p.CanUpdateAllMsg, err = strconv.ParseBool(args[5])
		internal.Check(err)
		p.CanDeleteAllMsg, err = strconv.ParseBool(args[6])
		internal.Check(err)
		p.AdminCanUpdateAllMsg, err = strconv.ParseBool(args[7])
		internal.Check(err)
		p.AdminCanDeleteAllMsg, err = strconv.ParseBool(args[8])
		internal.Check(err)
		p.IsAutoComputeTags, err = strconv.ParseBool(args[9])
		internal.Check(err)
		p.IsAutoComputeLabels, err = strconv.ParseBool(args[10])
		internal.Check(err)
		out, err := internal.Client().TopicParameter(p)
		internal.Check(err)
		if internal.Verbose {
			internal.Print(out)
		}
	},
}
示例#30
0
package user

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

var cmdUserDisableNotificationsTopic = &cobra.Command{
	Use:   "disableNotificationsTopic",
	Short: "Disable notifications on a topic: tatcli user disableNotificationsTopic <topicName>",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) == 1 {
			out, err := internal.Client().UserDisableNotificationsTopic(args[0])
			internal.Check(err)
			internal.Print(out)
		} else {
			internal.Exit("Invalid argument: tatcli user disableNotificationsTopic --help\n")
		}
	},
}