本文整理汇总了Golang中github.com/ovh/tatcli/internal.Print函数的典型用法代码示例。如果您正苦于以下问题:Golang Print函数的具体用法?Golang Print怎么用?Golang Print使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Print函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: 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
示例3:
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)
}
},
}
开发者ID:ovh,项目名称:tatcli,代码行数:30,代码来源:parameter.go
示例4:
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
示例5: Create
var cmdMessageAdd = &cobra.Command{
Use: "add",
Aliases: []string{"a"},
Short: "tatcli message add [--dateCreation=timestamp] <topic> <my message>",
Long: `Add a message to a Topic:
tatcli message add /Private/firstname.lastname my new messsage
`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) >= 2 {
topic := args[0]
message := strings.Join(args[1:], " ")
msg, err := Create(topic, message)
internal.Check(err)
if internal.Verbose {
internal.Print(msg)
}
} else {
internal.Exit("Invalid argument to add a message: tatcli msg add --help\n")
}
},
}
// 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, ";")
开发者ID:ovh,项目名称:tatcli,代码行数:30,代码来源:add.go
注:本文中的github.com/ovh/tatcli/internal.Print函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论