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


Golang brush.Green函数代码示例

本文整理汇总了Golang中github.com/aybabtme/color/brush.Green函数的典型用法代码示例。如果您正苦于以下问题:Golang Green函数的具体用法?Golang Green怎么用?Golang Green使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Green函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Success

func Success(title, hl, msg string) {
	if PureMode {
		success(title, hl, msg)
		return
	}

	if !Verbose {
		return
	}
	if len(hl) > 0 {
		hl = " " + brush.Green(hl).String()
	}
	fmt.Printf("gopm %s%s %s\n", brush.Green(title), hl, msg)
}
开发者ID:kulasama,项目名称:gopm,代码行数:14,代码来源:log.go

示例2: installToolchains

func installToolchains(langs []toolchainInstaller) error {
	var notInstalled []string
	for _, l := range langs {
		fmt.Println(brush.Cyan(l.name + " " + strings.Repeat("=", 78-len(l.name))).String())
		if err := l.fn(); err != nil {
			if err2, ok := err.(skippedToolchain); ok {
				fmt.Printf("%s\n", brush.Yellow(err2.Error()))
			} else {
				fmt.Printf("%s\n", brush.Red(fmt.Sprintf("failed to install/upgrade %s toolchain: %s", l.name, err)))
			}
			notInstalled = append(notInstalled, l.name)
			// Continue here because we attempt to install
			// all the toolchains.
			continue
		}

		fmt.Println(brush.Green("OK! Installed/upgraded " + l.name + " toolchain").String())
		fmt.Println(brush.Cyan(strings.Repeat("=", 80)).String())
		fmt.Println()
	}
	if len(notInstalled) != 0 {
		return errors.New(brush.Red(fmt.Sprintf("The following toolchains were not installed:\n%s", strings.Join(notInstalled, "\n"))).String())
	}
	return nil
}
开发者ID:vkz,项目名称:srclib,代码行数:25,代码来源:toolchain_cmd.go

示例3: DisplayPullRequests

func DisplayPullRequests(c *cli.Context, pulls []*gh.PullRequest, notrunc bool) {
	w := newTabwriter()
	fmt.Fprintf(w, "NUMBER\tLAST UPDATED\tTITLE")
	if c.Bool("lgtm") {
		fmt.Fprintf(w, "\tLGTM")
	}
	fmt.Fprintf(w, "\n")
	for _, p := range pulls {
		if !notrunc {
			p.Title = truncate(p.Title)
		}
		fmt.Fprintf(w, "%d\t%s\t%s", p.Number, HumanDuration(time.Since(p.UpdatedAt)), p.Title)
		if c.Bool("lgtm") {
			lgtm := strconv.Itoa(p.ReviewComments)
			if p.ReviewComments >= 2 {
				lgtm = brush.Green(lgtm).String()
			}
			fmt.Fprintf(w, "\t%s", lgtm)
		}
		fmt.Fprintf(w, "\n")
	}

	if err := w.Flush(); err != nil {
		fmt.Fprintf(os.Stderr, "%s", err)
	}
}
开发者ID:jamtur01,项目名称:pulls,代码行数:26,代码来源:display.go

示例4: dropCmd

func dropCmd(c *cli.Context) {
	if !c.Args().Present() {
		gordon.Fatalf("usage: drop 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 user == nil {
		gordon.Fatalf("%v", gordon.ErrNoUsernameKnown)
	}
	if pr.Assignee == nil || pr.Assignee.Login != user.Login {
		gordon.Fatalf("Can't drop %s: it's not yours.", number)
	}
	pr.Assignee = nil
	if _, err := m.PatchPullRequest(number, pr); err != nil {
		gordon.Fatalf("%s", err)
	}
	fmt.Printf("Unassigned PR %s\n", brush.Green(number))
}
开发者ID:askb,项目名称:gordon,代码行数:25,代码来源:main.go

示例5: approveCmd

// Approve a pr by adding a LGTM to the comments
func approveCmd(c *cli.Context) {
	number := c.Args().First()
	if _, err := m.AddComment(number, "LGTM"); err != nil {
		pulls.WriteError("%s", err)
	}
	fmt.Fprintf(os.Stdout, "Pull request %s approved\n", brush.Green(number))
}
开发者ID:jamtur01,项目名称:pulls,代码行数:8,代码来源:main.go

示例6: main

func main() {
	// Default Brush are available for your convenience.  You can invoke
	// them directly
	fmt.Printf("This is %s\n", brush.Red("red"))

	// or you can create new ones!
	weird := color.NewBrush(color.PurplePaint, color.CyanPaint)
	fmt.Printf("This color is %s\n", weird("weird"))

	// Create a Style, which has convenience methods
	redBg := color.NewStyle(color.RedPaint, color.YellowPaint)

	// Style.WithForeground or WithBackground returns a new Style, with the applied
	// Paint.  Styles are immutable so the original one is left unchanged
	greenFg := redBg.WithForeground(color.GreenPaint)

	// Style.Brush gives you a Brush that you can invoke directly to colorize strings.
	green := greenFg.Brush()
	fmt.Printf("This is %s but not really\n", green("kind of green"))

	// You can use it with all sorts of things
	sout := log.New(os.Stdout, "["+brush.Green("OK").String()+"]\t", log.LstdFlags)
	serr := log.New(os.Stderr, "["+brush.Red("OMG").String()+"]\t", log.LstdFlags)

	sout.Printf("Everything was going %s until...", brush.Cyan("fine"))
	serr.Printf("%s killed %s !!!", brush.Red("Locke"), brush.Blue("Jacob"))

}
开发者ID:matm,项目名称:gobuild,代码行数:28,代码来源:sample.go

示例7: 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:pombredanne,项目名称:pulls,代码行数:32,代码来源:main.go

示例8: 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:pombredanne,项目名称:pulls,代码行数:11,代码来源:main.go

示例9: approveCmd

// Approve a pr by adding a LGTM to the comments
func approveCmd(c *cli.Context) {
	if !c.Args().Present() {
		fmt.Println("Please enter a pull request number")
		return
	}
	number := c.Args().First()
	if _, err := m.AddComment(number, "LGTM"); err != nil {
		gordon.WriteError("%s", err)
	}
	fmt.Fprintf(os.Stdout, "Pull request %s approved\n", brush.Green(number))
}
开发者ID:rogaha,项目名称:gordon,代码行数:12,代码来源:main.go

示例10: printIssue

func printIssue(c *cli.Context, w *tabwriter.Writer, number int, updatedAt time.Time, login string, title string, comments int) {
	fmt.Fprintf(w, "%d\t%s\t%s\t%s", number, HumanDuration(time.Since(updatedAt)), login, title)
	if c.Int("votes") > 0 {
		votes := strconv.Itoa(comments)
		if comments >= 2 {
			votes = brush.Green(votes).String()
		}
		fmt.Fprintf(w, "\t%s", votes)
	}
	fmt.Fprintf(w, "\n")
}
开发者ID:rogaha,项目名称:gordon,代码行数:11,代码来源:display.go

示例11: mergeCmd

func mergeCmd(c *cli.Context) {
	number := c.Args()[0]
	merge, err := m.MergePullRequest(number, c.String("m"), c.Bool("force"))
	if err != nil {
		pulls.WriteError("%s", err)
	}
	if merge.Merged {
		fmt.Fprintf(os.Stdout, "%s\n", brush.Green(merge.Message))
	} else {
		pulls.WriteError("%s", err)
	}
}
开发者ID:jamtur01,项目名称:pulls,代码行数:12,代码来源:main.go

示例12: ColorizeDiff

// ColorizeDiff takes a byte slice of lines and returns the same, but with diff
// highlighting. That is, lines starting with '+' are green and lines starting
// with '-' are red.
func ColorizeDiff(diff []byte) []byte {
	lines := bytes.Split(diff, []byte{'\n'})
	for i, line := range lines {
		if bytes.HasPrefix(line, []byte{'-'}) {
			lines[i] = []byte(brush.Red(string(line)).String())
		}
		if bytes.HasPrefix(line, []byte{'+'}) {
			lines[i] = []byte(brush.Green(string(line)).String())
		}
	}
	return bytes.Join(lines, []byte{'\n'})
}
开发者ID:sombr,项目名称:ccat,代码行数:15,代码来源:test_cmd.go

示例13: DisplayIssue

func DisplayIssue(issue *gh.Issue, comments []gh.Comment) {
	fmt.Fprint(os.Stdout, brush.Green("Issue:"), "\n")
	fmt.Fprintf(os.Stdout, "No: %d\nTitle: %s\n\n", issue.Number, issue.Title)

	lines := strings.Split(issue.Body, "\n")
	for i, l := range lines {
		lines[i] = "\t" + l
	}
	fmt.Fprintf(os.Stdout, "Description:\n\n%s\n\n", strings.Join(lines, "\n"))
	fmt.Fprintf(os.Stdout, "\n\n")

	DisplayComments(comments)
}
开发者ID:rogaha,项目名称:gordon,代码行数:13,代码来源:display.go

示例14: DisplayPullRequest

func DisplayPullRequest(pr *gh.PullRequest, comments []gh.Comment) {
	fmt.Fprint(os.Stdout, brush.Green("Pull Request:"), "\n")
	fmt.Fprintf(os.Stdout, "No: %d\nTitle: %s\n\n", pr.Number, pr.Title)

	lines := strings.Split(pr.Body, "\n")
	for i, l := range lines {
		lines[i] = "\t" + l
	}
	fmt.Fprintf(os.Stdout, "Description:\n\n%s\n\n", strings.Join(lines, "\n"))
	fmt.Fprintf(os.Stdout, "\n\n")

	DisplayComments(comments)
}
开发者ID:jamtur01,项目名称:pulls,代码行数:13,代码来源:display.go

示例15: 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:pombredanne,项目名称:pulls,代码行数:15,代码来源:main.go


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