本文整理匯總了Golang中github.com/dotcloud/gordon.Fatalf函數的典型用法代碼示例。如果您正苦於以下問題:Golang Fatalf函數的具體用法?Golang Fatalf怎麽用?Golang Fatalf使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Fatalf函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: authCmd
func authCmd(c *cli.Context) {
config, err := gordon.LoadConfig()
if err != nil {
config = &gordon.Config{}
}
token := c.String("add")
userName := c.String("user")
if userName != "" {
config.UserName = userName
if err := gordon.SaveConfig(*config); err != nil {
gordon.Fatalf("%s", err)
}
}
if token != "" {
config.Token = token
if err := gordon.SaveConfig(*config); err != nil {
gordon.Fatalf("%s", err)
}
}
// Display token and user information
if config, err := gordon.LoadConfig(); err == nil {
if config.UserName != "" {
fmt.Printf("Token: %s, UserName: %s\n", config.Token, config.UserName)
} else {
fmt.Printf("Token: %s\n", config.Token)
}
} else {
fmt.Fprintf(os.Stderr, "No token registered\n")
os.Exit(1)
}
}
示例2: takeCmd
//Assign a pull request to the current user.
// If it's taken, show a message with the "--steal" optional flag.
//If the user doesn't have permissions, add a comment #volunteer
func takeCmd(c *cli.Context) {
if !c.Args().Present() {
gordon.Fatalf("usage: take ID")
}
number := c.Args()[0]
pr, err := m.GetPullRequest(number)
if err != nil {
gordon.Fatalf("%s", err)
}
user, err := m.GetGithubUser()
if err != nil {
gordon.Fatalf("%s", err)
}
if pr.Assignee != nil && !c.Bool("steal") {
gordon.Fatalf("Use --steal to steal the PR from %s", pr.Assignee.Login)
}
pr.Assignee = user
patchedPR, err := m.PatchPullRequest(number, pr)
if err != nil {
gordon.Fatalf("%s", err)
}
if patchedPR.Assignee.Login != user.Login {
m.AddComment(number, "#volunteer")
fmt.Printf("No permission to assign. You '%s' was added as #volunteer.\n", user.Login)
} else {
m.AddComment(number, fmt.Sprintf("#assignee=%s", patchedPR.Assignee.Login))
fmt.Printf("Assigned PR %s to %s\n", brush.Green(number), patchedPR.Assignee.Login)
}
}
示例3: reviewersCmd
// Show the reviewers for this pull request
func reviewersCmd(c *cli.Context) {
if !c.Args().Present() {
gordon.Fatalf("usage: reviewers ID")
}
var (
patch io.Reader
number = c.Args()[0]
)
if number == "-" {
patch = os.Stdin
} else {
pr, err := m.GetPullRequest(number)
if err != nil {
gordon.Fatalf("%s", err)
}
resp, err := http.Get(pr.DiffURL)
if err != nil {
gordon.Fatalf("%s", err)
}
patch = resp.Body
defer resp.Body.Close()
}
reviewers, err := gordon.GetReviewersForPR(patch, false)
if err != nil {
gordon.Fatalf("%s", err)
}
gordon.DisplayReviewers(c, reviewers)
}
示例4: commentCmd
func commentCmd(c *cli.Context) {
if !c.Args().Present() {
gordon.Fatalf("Please enter the issue's number")
}
number := c.Args()[0]
editor := os.Getenv("EDITOR")
if editor == "" {
editor = "nano"
}
tmp, err := ioutil.TempFile("", "pulls-comment-")
if err != nil {
gordon.Fatalf("%s", err)
}
defer os.Remove(tmp.Name())
cmd := exec.Command(editor, tmp.Name())
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
gordon.Fatalf("%v", err)
}
comment, err := ioutil.ReadAll(tmp)
if err != nil {
gordon.Fatalf("%v", err)
}
if _, err := m.AddComment(number, string(comment)); err != nil {
gordon.Fatalf("%v", err)
}
}
示例5: displayAllPullRequests
func displayAllPullRequests(c *cli.Context) {
prs, err := m.GetPullRequests(c.String("state"), c.String("sort"))
if err != nil {
gordon.Fatalf("Error getting pull requests %s", err)
}
var needFullPr, needComments bool
if c.Bool("no-merge") {
needFullPr = true
}
if c.Bool("lgtm") {
needComments = true
}
if needFullPr || needComments {
prs = m.GetFullPullRequests(prs, needFullPr, needComments)
}
prs, err = filters.FilterPullRequests(c, prs)
if err != nil {
gordon.Fatalf("Error filtering pull requests %s", err)
}
fmt.Printf("%c[2K\r", 27)
gordon.DisplayPullRequests(c, prs, c.Bool("no-trunc"))
}
示例6: approveCmd
// Approve a pr by adding a LGTM to the comments
func approveCmd(c *cli.Context) {
if !c.Args().Present() {
gordon.Fatalf("usage: approve ID")
}
number := c.Args().First()
if _, err := m.AddComment(number, "LGTM"); err != nil {
gordon.Fatalf("%s", err)
}
fmt.Printf("Pull request %s approved\n", brush.Green(number))
}
示例7: closeCmd
func closeCmd(c *cli.Context) {
if !c.Args().Present() {
gordon.Fatalf("Please enter the issue's number")
}
number := c.Args()[0]
if err := m.Close(number); err != nil {
gordon.Fatalf("%v", err)
}
fmt.Printf("Closed PR %s\n", number)
}
示例8: commentsCmd
func commentsCmd(c *cli.Context) {
if !c.Args().Present() {
gordon.Fatalf("usage: comments ID")
}
comments, err := m.GetComments(c.Args().First())
if err != nil {
gordon.Fatalf("%s", err)
}
gordon.DisplayComments(comments)
}
示例9: checkoutCmd
func checkoutCmd(c *cli.Context) {
if !c.Args().Present() {
gordon.Fatalf("usage: checkout ID")
}
number := c.Args()[0]
pr, err := m.GetPullRequest(number)
if err != nil {
gordon.Fatalf("%s", err)
}
if err := m.Checkout(pr); err != nil {
gordon.Fatalf("%s", err)
}
}
示例10: mergeCmd
func mergeCmd(c *cli.Context) {
if !c.Args().Present() {
gordon.Fatalf("usage: merge ID")
}
number := c.Args()[0]
merge, err := m.MergePullRequest(number, c.String("m"), c.Bool("force"))
if err != nil {
gordon.Fatalf("%s", err)
}
if merge.Merged {
fmt.Printf("%s\n", brush.Green(merge.Message))
} else {
gordon.Fatalf("%s", err)
}
}
示例11: repositoryInfoCmd
func repositoryInfoCmd(c *cli.Context) {
r, err := m.Repository()
if err != nil {
gordon.Fatalf("%s", err)
}
fmt.Printf("Name: %s\nForks: %d\nStars: %d\nIssues: %d\n", r.Name, r.Forks, r.Watchers, r.OpenIssues)
}
示例12: alruCmd
func alruCmd(c *cli.Context) {
lru, err := m.GetFirstPullRequest("open", "updated")
if err != nil {
gordon.Fatalf("Error getting pull requests: %s", err)
}
fmt.Printf("%v (#%d)\n", gordon.HumanDuration(time.Since(lru.UpdatedAt)), lru.Number)
}
示例13: addComment
func addComment(number, comment string) {
cmt, err := m.AddComment(number, comment)
if err != nil {
gordon.Fatalf("%s", err)
}
gordon.DisplayCommentAdded(cmt)
}
示例14: buildQuery
func buildQuery(c *cli.Context) string {
r, err := m.Repository()
if err != nil {
gordon.Fatalf("%s", err)
}
// standard parameters
query := fmt.Sprintf("q=%s+repo:%s", c.Args()[0], r.FullName)
state := c.String("state")
if state == "" {
state = "open"
}
query += fmt.Sprintf("+state:%s", state)
// optional parameters
var optionalParameters = []string{
"author",
"assignee",
"mentions",
"commenter",
"involves",
"labels"}
for i := 0; i < len(optionalParameters); i++ {
param := optionalParameters[i]
value := c.String(param)
if value != "" {
query += fmt.Sprintf("+%s:%s", param, value)
}
}
return query
}
示例15: contributorsCmd
// Show contributors stats
func contributorsCmd(c *cli.Context) {
contributors, err := m.GetContributors()
if err != nil {
gordon.Fatalf("%s", err)
}
gordon.DisplayContributors(c, contributors)
}