本文整理汇总了Golang中github.com/ovh/tatcli/internal.Client函数的典型用法代码示例。如果您正苦于以下问题:Golang Client函数的具体用法?Golang Client怎么用?Golang Client使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Client函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: topicTruncate
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")
}
}
开发者ID:ovh,项目名称:tatcli,代码行数:29,代码来源:truncate.go
示例2: sendSimpleActionMsg
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
}
}
开发者ID:ovh,项目名称:tatcli,代码行数:34,代码来源:send.go
示例3: updateTopics
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()
}
开发者ID:ovh,项目名称:tatcli,代码行数:60,代码来源:topics.go
示例4: sendMsg
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()
}
开发者ID:ovh,项目名称:tatcli,代码行数:26,代码来源:send.go
示例5: updateMessagesPane
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()
}
开发者ID:ovh,项目名称:tatcli,代码行数:25,代码来源:messages.go
示例6: updateMessage
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 = ""
}
开发者ID:ovh,项目名称:tatcli,代码行数:26,代码来源:message.go
示例7: removeLabel
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
}
开发者ID:ovh,项目名称:tatcli,代码行数:16,代码来源:messages.go
示例8: monitoringActionOnMessage
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()
}
开发者ID:ovh,项目名称:tatcli,代码行数:45,代码来源:messages.go
示例9: topicAddParameter
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)
}
}
开发者ID:ovh,项目名称:tatcli,代码行数:10,代码来源:add_parameter.go
示例10: showVersion
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
}
开发者ID:ovh,项目名称:tatcli,代码行数:11,代码来源:send.go
示例11: sendUnlabel
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
}
}
开发者ID:ovh,项目名称:tatcli,代码行数:15,代码来源:send.go
示例12: Create
// 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)
}
开发者ID:ovh,项目名称:tatcli,代码行数:17,代码来源:add.go
示例13: showMe
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))
}
开发者ID:ovh,项目名称:tatcli,代码行数:17,代码来源:send.go
示例14: loadArgs
// 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
}
开发者ID:ovh,项目名称:tatcli,代码行数:46,代码来源:ui.go
示例15: userVerify
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))
}
}
开发者ID:ovh,项目名称:tatcli,代码行数:20,代码来源:verify.go
示例16: sendLabel
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
}
}
开发者ID:ovh,项目名称:tatcli,代码行数:20,代码来源:send.go
示例17:
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")
}
},
}
开发者ID:ovh,项目名称:tatcli,代码行数:23,代码来源:set_admin.go
示例18: runActionOnMessage
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()
}
开发者ID:ovh,项目名称:tatcli,代码行数:68,代码来源:messages.go
示例19:
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")
}
},
}
开发者ID:ovh,项目名称:tatcli,代码行数:29,代码来源:create.go
示例20: init
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")
}
},
}
开发者ID:ovh,项目名称:tatcli,代码行数:23,代码来源:delete_parameter.go
注:本文中的github.com/ovh/tatcli/internal.Client函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论