本文整理匯總了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
}