• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang brush.Green函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: mergeCmd

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


示例17: checkResults

func checkResults(output bytes.Buffer, treeDir, actualDir, expectedDir string) error {
	treeName := filepath.Base(treeDir)
	out, err := exec.Command("diff", "-ur", expectedDir, actualDir).CombinedOutput()
	if err != nil || len(out) > 0 {
		fmt.Println(brush.Red(treeName + " FAIL").String())
		fmt.Printf("Diff failed for %s: %s.", treeName, err)
		if len(out) > 0 {
			fmt.Println(brush.Red(treeName + " FAIL"))
			fmt.Println(output.String())
			fmt.Println(string(ColorizeDiff(out)))
		}
		return fmt.Errorf("Output for %s differed from expected.", treeName)
	} else {
		fmt.Println(brush.Green(treeName + " PASS").String())
	}
	return nil
}
开发者ID:sombr,项目名称:ccat,代码行数:17,代码来源:test_cmd.go


示例18: DisplayPatch

func DisplayPatch(r io.Reader) error {
	s := bufio.NewScanner(r)
	for s.Scan() {
		if err := s.Err(); err != nil {
			return err
		}
		t := s.Text()

		switch t[0] {
		case '-':
			fmt.Fprintln(os.Stdout, brush.Red(t))
		case '+':
			fmt.Fprintln(os.Stdout, brush.Green(t))
		default:
			fmt.Fprintln(os.Stdout, t)
		}
	}
	return nil
}
开发者ID:rogaha,项目名称:gordon,代码行数:19,代码来源:display.go


示例19: makeLogMux

func makeLogMux(conf *Config) (*logMux, error) {

	fileVerb, err := getVerbosityLevel(conf.LogFileVerbosity)
	if err != nil {
		return nil, fmt.Errorf("log file verbosity, %v", err)
	}
	consoleVerb, err := getVerbosityLevel(conf.ConsoleVerbosity)
	if err != nil {
		return nil, fmt.Errorf("console verbosity, %v", err)
	}

	filename := conf.LogFilename

	file, err := os.OpenFile(filename, os.O_APPEND|os.O_WRONLY, 0640)
	if os.IsNotExist(err) {
		file, err = os.Create(filename)
	}
	if err != nil {
		return nil, fmt.Errorf("opening log file %s, %v", filename, err)
	}

	debugPfx := fmt.Sprintf("%s%s%s ",
		brush.DarkGray("["),
		brush.Blue("DEBUG"),
		brush.DarkGray("]"))

	watchPfx := fmt.Sprintf("%s%s%s ",
		brush.DarkGray("["),
		brush.DarkCyan("WATCH"),
		brush.DarkGray("]"))

	infoPfx := fmt.Sprintf(" %s%s%s ",
		brush.DarkGray("["),
		brush.Green("INFO"),
		brush.DarkGray("]"))

	warnPfx := fmt.Sprintf(" %s%s%s ",
		brush.DarkGray("["),
		brush.Yellow("WARN"),
		brush.DarkGray("]"))

	errPfx := fmt.Sprintf("%s%s%s ",
		brush.DarkGray("["),
		brush.Red("ERROR"),
		brush.DarkGray("]"))

	return &logMux{
		logFile:        file,
		debugFile:      log.New(file, "[DEBUG] ", log.LstdFlags),
		watchFile:      log.New(file, "[WATCH] ", log.LstdFlags),
		infoFile:       log.New(file, " [INFO] ", log.LstdFlags),
		warnFile:       log.New(file, " [WARN] ", log.LstdFlags),
		errorFile:      log.New(file, "[ERROR] ", log.LstdFlags),
		debugConsole:   log.New(os.Stdout, debugPfx, log.LstdFlags),
		watchConsole:   log.New(os.Stdout, watchPfx, log.LstdFlags),
		infoConsole:    log.New(os.Stdout, infoPfx, log.LstdFlags),
		warnConsole:    log.New(os.Stdout, warnPfx, log.LstdFlags),
		errorConsole:   log.New(os.Stderr, errPfx, log.LstdFlags),
		fileVerbose:    fileVerb,
		consoleVerbose: consoleVerb,
	}, nil
}
开发者ID:RafehSaeed,项目名称:brog,代码行数:62,代码来源:log.go


示例20: init

)

var stdout_std_logger *log.Logger
var stderr_std_logger *log.Logger

var prefixes = map[int]string{
	DEBUG:   "[debug] ",
	INFO:    "[info] ",
	WARNING: "[warning] ",
	ERROR:   "[error] ",
	FATAL:   "[fatal] ",
}

var coloredPrefixes = map[int]string{
	DEBUG:   brush.Cyan("[debug] ").String(),
	INFO:    brush.Green("[info] ").String(),
	WARNING: brush.Yellow("[warning] ").String(),
	ERROR:   brush.Red("[error] ").String(),
	FATAL:   brush.DarkRed("[fatal] ").String(),
}

type Stdout struct {
	MinLevel int
	Colored  bool
}

func init() {
	stdout_std_logger = log.New(os.Stdout, "", log.Ldate|log.Ltime|log.Lshortfile)
	stderr_std_logger = log.New(os.Stderr, "", log.Ldate|log.Ltime|log.Lshortfile)
}
开发者ID:pzduniak,项目名称:logger,代码行数:30,代码来源:stdout.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang raymond.Options类代码示例发布时间:2022-05-24
下一篇:
Golang types.Underlying函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap