当前位置: 首页>>代码示例>>Golang>>正文


Golang gordon.Fatalf函数代码示例

本文整理汇总了Golang中github.com/docker/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)
	}
}
开发者ID:rm3l,项目名称:gordon,代码行数:32,代码来源:main.go

示例2: 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"))
}
开发者ID:rm3l,项目名称:gordon,代码行数:27,代码来源:main.go

示例3: 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)
	}
}
开发者ID:rm3l,项目名称:gordon,代码行数:32,代码来源:main.go

示例4: takeCmd

//Take a specific issue. If it's taken, show a message with the overwrite optional flag
//If the user doesn't have permissions, add a comment #volunteer
func takeCmd(c *cli.Context) {
	if c.Args().Present() {
		number := c.Args()[0]
		issue, _, err := m.GetIssue(number, false)
		if err != nil {
			gordon.Fatalf("%s", err)
		}
		user, err := m.GetGithubUser()
		if err != nil {
			gordon.Fatalf("%s", err)
		}
		if user == nil {
			gordon.Fatalf("%v", gordon.ErrNoUsernameKnown)
		}
		if issue.Assignee.Login != "" && !c.Bool("overwrite") {
			fmt.Printf("Use the flag --overwrite to take the issue from %s\n", issue.Assignee.Login)
			return
		}
		issue.Assignee = *user
		patchedIssue, err := m.PatchIssue(number, issue)
		if err != nil {
			gordon.Fatalf("%s", err)
		}
		if patchedIssue.Assignee.Login != user.Login {
			m.AddComment(number, "#volunteer")
			fmt.Printf("No permission to assign. You '%s' was added as #volunteer.\n", user.Login)
		} else {
			fmt.Printf("The issue %s was assigned to %s\n", number, patchedIssue.Assignee.Login)
		}
	} else {
		fmt.Printf("Please enter the issue's number\n")
	}

}
开发者ID:askb,项目名称:gordon,代码行数:36,代码来源:main.go

示例5: 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)
	}
}
开发者ID:rm3l,项目名称:gordon,代码行数:29,代码来源:main.go

示例6: compareCmd

// compareCmd searches to find Merge commits that are in master that are not in the branch
func compareCmd(c *cli.Context) {

	// TODO: don't repase all history to the begining of time (--after?)

	if nArgs := len(c.Args()); nArgs == 2 {
		// git log --format=oneline upstream/master > master.log
		masterLog, err := git("log", "--format=format:%H %s %b", c.Args()[0])
		if err != nil {
			gordon.Fatalf("%v", err)
		}

		// git log --format=oneline upstream/docs > docs.log
		branchLog, err := git("log", "--format=format:%H %s %b", c.Args()[1])
		if err != nil {
			gordon.Fatalf("%v", err)
		}

		// diff -U 0 master.log docs.log  | grep "Merge pull" | sed "s/^-/- /g"
		// Parse both logs looking for 'Merge pull request #`
		reMergeLine := regexp.MustCompile(`^([0-9a-f]{40}) Merge pull request #([0-9]*) from (.*)$`)
		branchPRs := make(map[string]string)
		s := bufio.NewScanner(strings.NewReader(branchLog))
		for s.Scan() {
			res := reMergeLine.FindStringSubmatch(s.Text())
			if res == nil {
				continue
			}
			hash := res[1]
			pr := res[2]
			//desc := res[3]
			branchPRs[pr] = hash
		}

		firstMerged := ""
		s = bufio.NewScanner(strings.NewReader(masterLog))
		for s.Scan() {
			res := reMergeLine.FindStringSubmatch(s.Text())
			if res == nil {
				continue
			}
			hash := res[1]
			pr := res[2]
			desc := res[3]

			if branchPRs[pr] == "" {
				// TODO: consider reversing the order of this list to match the commit list in the GH PR
				fmt.Printf("- %s #%s : %s\n", hash, pr, desc)
			} else if firstMerged == "" {
				firstMerged = pr
				fmt.Println("------- ^^^^ un-considered candidates")
			}
		}
	} else {
		gordon.Fatalf("Usage: compare [branch] [branch]")
	}
}
开发者ID:askb,项目名称:gordon,代码行数:57,代码来源:main.go

示例7: 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))
}
开发者ID:rm3l,项目名称:gordon,代码行数:11,代码来源:main.go

示例8: 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)
}
开发者ID:rm3l,项目名称:gordon,代码行数:10,代码来源:main.go

示例9: 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)
}
开发者ID:rm3l,项目名称:gordon,代码行数:10,代码来源:main.go

示例10: 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)
	}
}
开发者ID:rm3l,项目名称:gordon,代码行数:13,代码来源:main.go

示例11: 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)
	}
}
开发者ID:rm3l,项目名称:gordon,代码行数:15,代码来源:main.go

示例12: 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)
}
开发者ID:rm3l,项目名称:gordon,代码行数:7,代码来源:main.go

示例13: 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
}
开发者ID:askb,项目名称:gordon,代码行数:30,代码来源:main.go

示例14: addComment

func addComment(number, comment string) {
	cmt, err := m.AddComment(number, comment)
	if err != nil {
		gordon.Fatalf("%s", err)
	}
	gordon.DisplayCommentAdded(cmt)
}
开发者ID:rm3l,项目名称:gordon,代码行数:7,代码来源:main.go

示例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)
}
开发者ID:rm3l,项目名称:gordon,代码行数:8,代码来源:main.go


注:本文中的github.com/docker/gordon.Fatalf函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。