本文整理汇总了Golang中github.com/disorganizer/brig/daemon.Client.Status方法的典型用法代码示例。如果您正苦于以下问题:Golang Client.Status方法的具体用法?Golang Client.Status怎么用?Golang Client.Status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/disorganizer/brig/daemon.Client
的用法示例。
在下文中一共展示了Client.Status方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: handleCommit
func handleCommit(ctx *cli.Context, client *daemon.Client) error {
message := ctx.String("message")
if message == "" {
message = fmt.Sprintf("Update on %s", time.Now().String())
}
status, err := client.Status()
if err != nil {
return err
}
statusCmt := status.Commit
if statusCmt == nil {
return fmt.Errorf("Empty status commit in response.")
}
commitCnt := len(statusCmt.Changeset)
if commitCnt == 0 {
fmt.Println("Nothing to commit.")
return nil
}
if commitCnt != 1 {
fmt.Printf("%d changes commited.\n", commitCnt)
} else {
fmt.Printf("%d change commited.\n", commitCnt)
}
return client.MakeCommit(message)
}
示例2: handleStatus
func handleStatus(ctx *cli.Context, client *daemon.Client) error {
status, err := client.Status()
if err != nil {
return err
}
statusCmt := status.Commit
if statusCmt == nil {
return fmt.Errorf("Empty status commit in response.")
}
checkpoints := statusCmt.Checkpoints
if len(checkpoints) == 0 {
fmt.Println("Nothing to commit.")
return nil
}
userToChanges := make(map[id.ID]changeByType)
for _, pckp := range checkpoints {
byAuthor, ok := userToChanges[id.ID(pckp.Author)]
if !ok {
byAuthor = make(changeByType)
userToChanges[id.ID(pckp.Author)] = byAuthor
}
byAuthor[pckp.Change] = append(byAuthor[pckp.Change], pckp)
}
for user, changesByuser := range userToChanges {
fmt.Printf(
"Changes by %s:\n",
colors.Colorize(string(user), colors.Magenta),
)
printChangesByUser(changesByuser)
}
return nil
}