本文整理匯總了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")
}
}
示例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))
}
}
示例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)
}
},
}
示例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")
}
},
}
示例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, ";")