Esempio n. 1
0
File: log.go Progetto: gocore/goal
func init() {
	// Initialize default loggers.
	Error = log.New(
		&context{
			c: color.New(color.FgRed, color.Bold),
			w: os.Stderr,
		}, "", 0,
	)
	Warn = log.New(
		&context{
			c: color.New(color.FgYellow),
			w: os.Stderr,
		}, "", 0,
	)
	Info = log.New(
		&context{
			c: color.New(color.FgGreen),
			w: os.Stdout,
		}, "", 0,
	)
	Trace = log.New(
		&context{
			c: color.New(color.FgCyan),
			w: os.Stdout,
		}, "", 0,
	)
}
Esempio n. 2
0
// mainList - is a handler for mc ls command
func mainList(ctx *cli.Context) {
	checkListSyntax(ctx)

	args := ctx.Args()
	// Operating system tool behavior
	if globalMimicFlag && !ctx.Args().Present() {
		args = []string{"."}
	}

	console.SetCustomTheme(map[string]*color.Color{
		"File": color.New(color.FgWhite),
		"Dir":  color.New(color.FgCyan, color.Bold),
		"Size": color.New(color.FgYellow),
		"Time": color.New(color.FgGreen),
	})

	config := mustGetMcConfig()
	for _, arg := range args {
		targetURL, err := getCanonicalizedURL(arg, config.Aliases)
		fatalIf(err.Trace(arg), "Unable to parse argument ‘"+arg+"’.")

		// if recursive strip off the "..."
		err = doListCmd(stripRecursiveURL(targetURL), isURLRecursive(targetURL))
		fatalIf(err.Trace(targetURL), "Unable to list target ‘"+targetURL+"’.")
	}
}
Esempio n. 3
0
// runTestsViaRunner runs all the tests at the given source path via the runner.
func runTestsViaRunner(runner TestRunner, path string) bool {
	log.Printf("Starting test run of %s via %v runner", path, runner.Title())

	// Run setup for the runner.
	err := runner.SetupIfNecessary()
	if err != nil {
		errHighlight := color.New(color.FgRed, color.Bold)
		errHighlight.Print("ERROR: ")

		text := color.New(color.FgWhite)
		text.Printf("Could not setup %s runner: %v\n", runner.Title(), err)
		return false
	}

	// Iterate over each test file in the source path. For each, compile the code into
	// JS at a temporary location and then pass the temporary location to the test
	// runner.
	return compilerutil.WalkSourcePath(path, func(currentPath string, info os.FileInfo) (bool, error) {
		if !strings.HasSuffix(info.Name(), "_test"+parser.SERULIAN_FILE_EXTENSION) {
			return false, nil
		}

		success, err := buildAndRunTests(currentPath, runner)
		if err != nil {
			return true, err
		}

		if success {
			return true, nil
		} else {
			return true, fmt.Errorf("Failure in test of file %s", currentPath)
		}
	})
}
Esempio n. 4
0
func PrintUnassignedWarning(writer io.Writer, commits []*git.Commit) (n int64, err error) {
	var output bytes.Buffer

	// Let's be colorful!
	redBold := color.New(color.FgRed).Add(color.Bold).SprintFunc()
	fmt.Fprint(&output,
		redBold("Warning: There are some commits missing the Story-Id tag.\n"))

	red := color.New(color.FgRed).SprintFunc()
	fmt.Fprint(&output,
		red("Make sure that this is alright before proceeding further.\n\n"))

	hashRe := regexp.MustCompile("^[0-9a-f]{40}$")

	yellow := color.New(color.FgYellow).SprintFunc()

	for _, commit := range commits {
		var (
			sha    = commit.SHA
			source = commit.Source
			title  = prompt.ShortenCommitTitle(commit.MessageTitle)
		)
		if hashRe.MatchString(commit.Source) {
			source = "unknown commit source branch"
		}

		fmt.Fprintf(&output, "  %v | %v | %v\n", yellow(sha), yellow(source), title)
	}

	// Write the output to the writer.
	return io.Copy(ansicolor.NewAnsiColorWriter(writer), &output)
}
Esempio n. 5
0
// mainConfig is the handle for "mc config" sub-command. writes configuration data in json format to config file.
func mainConfig(ctx *cli.Context) {
	checkConfigSyntax(ctx)

	// set new custom coloring
	console.SetCustomTheme(map[string]*color.Color{
		"Alias":        color.New(color.FgCyan, color.Bold),
		"AliasMessage": color.New(color.FgGreen, color.Bold),
		"URL":          color.New(color.FgWhite),
	})

	arg := ctx.Args().First()
	tailArgs := ctx.Args().Tail()

	switch strings.TrimSpace(arg) {
	case "add":
		if strings.TrimSpace(tailArgs.First()) == "alias" {
			addAlias(tailArgs.Get(1), tailArgs.Get(2))
		}
	case "remove":
		if strings.TrimSpace(tailArgs.First()) == "alias" {
			removeAlias(tailArgs.Get(1))
		}
	case "list":
		if strings.TrimSpace(tailArgs.First()) == "alias" {
			listAliases()
		}
	}
}
Esempio n. 6
0
func (this *Wigo) GenerateSummary(showOnlyErrors bool) (summary string) {

	red := color.New(color.FgRed).SprintfFunc()
	yellow := color.New(color.FgYellow).SprintfFunc()

	summary += fmt.Sprintf("%s running on %s \n", this.Version, this.LocalHost.Name)
	summary += fmt.Sprintf("Local Status 	: %d\n", this.LocalHost.Status)
	summary += fmt.Sprintf("Global Status	: %d\n\n", this.GlobalStatus)

	if this.LocalHost.Status != 100 || !showOnlyErrors {
		summary += "Local probes : \n\n"

		for probeName := range this.LocalHost.Probes {
			if this.LocalHost.Probes[probeName].Status > 100 && this.LocalHost.Probes[probeName].Status < 300 {
				summary += yellow("\t%-25s : %d  %s\n", this.LocalHost.Probes[probeName].Name, this.LocalHost.Probes[probeName].Status, strings.Replace(this.LocalHost.Probes[probeName].Message, "%", "%%", -1))
			} else if this.LocalHost.Probes[probeName].Status >= 300 {
				summary += red("\t%-25s : %d  %s\n", this.LocalHost.Probes[probeName].Name, this.LocalHost.Probes[probeName].Status, strings.Replace(this.LocalHost.Probes[probeName].Message, "%", "%%", -1))
			} else {
				summary += fmt.Sprintf("\t%-25s : %d  %s\n", this.LocalHost.Probes[probeName].Name, this.LocalHost.Probes[probeName].Status, strings.Replace(this.LocalHost.Probes[probeName].Message, "%", "%%", -1))
			}
		}

		summary += "\n"
	}

	if this.GlobalStatus >= 200 && len(this.RemoteWigos) > 0 {
		summary += "Remote Wigos : \n\n"
	}

	summary += this.GenerateRemoteWigosSummary(0, showOnlyErrors, this.Version)

	return
}
Esempio n. 7
0
func StatusMessage(view *gocui.View, data interface{}) {
	yellow := color.New(color.FgYellow).SprintFunc()
	white := color.New(color.FgWhite).SprintFunc()

	timestamp := time.Now().Format("03:04")
	fmt.Fprintf(view, "-> [%s] * %s\n", yellow(timestamp), white(data))
}
Esempio n. 8
0
// mainList - is a handler for mc ls command
func mainList(ctx *cli.Context) {
	// Additional command speific theme customization.
	console.SetColor("File", color.New(color.FgWhite))
	console.SetColor("Dir", color.New(color.FgCyan, color.Bold))
	console.SetColor("Size", color.New(color.FgYellow))
	console.SetColor("Time", color.New(color.FgGreen))

	// check 'ls' cli arguments
	checkListSyntax(ctx)

	args := ctx.Args()
	isIncomplete := ctx.Bool("incomplete")

	// mimic operating system tool behavior
	if globalMimicFlag && !ctx.Args().Present() {
		args = []string{"."}
	}

	targetURLs, err := args2URLs(args.Head())
	fatalIf(err.Trace(args...), "One or more unknown URL types passed.")
	for _, targetURL := range targetURLs {
		// if recursive strip off the "..."
		var clnt client.Client
		clnt, err = url2Client(stripRecursiveURL(targetURL))
		fatalIf(err.Trace(targetURL), "Unable to initialize target ‘"+targetURL+"’.")

		err = doList(clnt, isURLRecursive(targetURL), isIncomplete)
		fatalIf(err.Trace(clnt.GetURL().String()), "Unable to list target ‘"+clnt.GetURL().String()+"’.")
	}
}
Esempio n. 9
0
func main() {
	cy := color.New(color.FgCyan).Add(color.BlinkSlow).PrintfFunc()
	ma := color.New(color.FgMagenta).Add(color.BlinkSlow).PrintfFunc()

	c1 := make(chan string)
	c2 := make(chan string)

	go func() {
		time.Sleep(time.Second * 1)
		c1 <- "one"
	}()

	go func() {
		time.Sleep(time.Second * 2)
		c2 <- "two"
	}()

	for i := 0; i < 2; i++ {
		select {
		case msg1 := <-c1:
			cy("received %v ", msg1)
			emoji.Printf(":beer:\n")
		case msg2 := <-c2:
			ma("received %v ", msg2)
			emoji.Printf(":pizza:")
		}
	}
	fmt.Println("")
}
Esempio n. 10
0
// shareSetColor sets colors share sub-commands.
func shareSetColor() {
	// Additional command speific theme customization.
	console.SetColor("Share", color.New(color.FgGreen, color.Bold))
	console.SetColor("Expires", color.New(color.FgRed, color.Bold))
	console.SetColor("URL", color.New(color.FgCyan, color.Bold))
	console.SetColor("File", color.New(color.FgRed, color.Bold))
}
Esempio n. 11
0
// mainList - is a handler for mc ls command
func mainList(ctx *cli.Context) {
	// Additional command speific theme customization.
	console.SetColor("File", color.New(color.FgWhite))
	console.SetColor("Dir", color.New(color.FgCyan, color.Bold))
	console.SetColor("Size", color.New(color.FgYellow))
	console.SetColor("Time", color.New(color.FgGreen))

	// Set global flags from context.
	setGlobalsFromContext(ctx)

	// check 'ls' cli arguments.
	checkListSyntax(ctx)

	// Set command flags from context.
	isRecursive := ctx.Bool("recursive")
	isIncomplete := ctx.Bool("incomplete")

	args := ctx.Args()
	// mimic operating system tool behavior.
	if !ctx.Args().Present() {
		args = []string{"."}
	}

	for _, targetURL := range args {
		var clnt client.Client
		clnt, err := newClient(targetURL)
		fatalIf(err.Trace(targetURL), "Unable to initialize target ‘"+targetURL+"’.")

		err = doList(clnt, isRecursive, isIncomplete)
		if err != nil {
			errorIf(err.Trace(clnt.GetURL().String()), "Unable to list target ‘"+clnt.GetURL().String()+"’.")
			continue
		}
	}
}
Esempio n. 12
0
func ExecuteCommand(c *template.Template, fname string) error {
	cmdStr, err := evalTemplate(c, &templateArg{File: fname})
	if err != nil {
		return err
	}

	cmd := exec.Command("bash", "-c", cmdStr)
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	cmd.Stdin = os.Stdin

	fmt.Println()
	color.New(color.Bold).Printf("Execute by letter > ")
	fmt.Println(cmdStr)

	err = cmd.Run()
	status, err := exitStatus(err)
	if err != nil {
		return err
	}
	color.New(color.Bold).Print("Finished command with status code ")

	var colorAttr color.Attribute
	if status == 0 {
		colorAttr = color.FgGreen
	} else {
		colorAttr = color.FgRed
	}
	color.New(color.Bold, colorAttr).Println(status)

	return nil
}
Esempio n. 13
0
//SetChannelState sets the Channel inside the State
func SetChannelState(dg *discordgo.Session) {
	State.InsertMode = false

	guild := State.Guild
	d := color.New(color.FgYellow, color.Bold)
	d.Printf("Select a Channel:\n")
	for key, channel := range guild.Channels {
		if channel.Type == "text" {
			fmt.Printf("%d:%s\n", key, channel.Name)
		}
	}

	var response int
	fmt.Scanf("%d\n", &response)
	for guild.Channels[response].Type != "text" {
		Error := color.New(color.FgRed, color.Bold)
		Error.Printf("That's a voice channel, you know this is a CLI right?\n")
		d.Printf("Select a Channel:\n")
		fmt.Scanf("%d\n", &response)
	}

	State.Channel = guild.Channels[response]

	Clear()

	State.InsertMode = true
}
Esempio n. 14
0
func (l *Summary) Print(out io.Writer, colored bool) {
	info := func(a ...interface{}) { fmt.Fprintln(out, a...) }
	warn := info
	fail := info
	success := info

	color.Output = out
	if colored {
		warn = color.New(color.FgYellow).PrintlnFunc()
		fail = color.New(color.FgRed).PrintlnFunc()
		success = color.New(color.FgGreen).PrintlnFunc()
	}
	if len(l.Errors) == 0 {
		message := "[OK] All is well!"
		success(message)
		return
	}

	for _, e := range l.Errors {
		switch e.Level {
		case 0:
			info(e.Error())
		case 1:
			warn(e.Error())
		case 2:
			fail(e.Error())
		}
	}
	if l.Severity() > 1 {
		message := "[CRITICAL] Some critical problems found."
		fail(message)
	}
}
Esempio n. 15
0
// mainDiff - is a handler for mc diff command
func mainDiff(ctx *cli.Context) {
	checkDiffSyntax(ctx)

	console.SetCustomTheme(map[string]*color.Color{
		"DiffMessage":     color.New(color.FgGreen, color.Bold),
		"DiffOnlyInFirst": color.New(color.FgRed, color.Bold),
		"DiffType":        color.New(color.FgYellow, color.Bold),
		"DiffSize":        color.New(color.FgMagenta, color.Bold),
	})

	config := mustGetMcConfig()
	firstArg := ctx.Args().First()
	secondArg := ctx.Args().Last()

	firstURL, err := getCanonicalizedURL(firstArg, config.Aliases)
	fatalIf(err.Trace(firstArg), "Unable to parse first argument ‘"+firstArg+"’.")

	secondURL, err := getCanonicalizedURL(secondArg, config.Aliases)
	fatalIf(err.Trace(secondArg), "Unable to parse second argument ‘"+secondArg+"’.")

	newFirstURL := stripRecursiveURL(firstURL)
	for diff := range doDiffCmd(newFirstURL, secondURL, isURLRecursive(firstURL)) {
		fatalIf(diff.Error.Trace(newFirstURL, secondURL), "Failed to diff ‘"+firstURL+"’ and ‘"+secondURL+"’.")
		console.Println(diff.String())
	}
}
Esempio n. 16
0
func FetchHTMLDoc(url string) (doc *goquery.Document, err error) {

	retries := 15

	err = errors.New("Init Errir")
	for retries > 0 && err != nil {

		doc, err = goquery.NewDocument(url)
		if err != nil {
			c := color.New(color.FgMagenta)
			c.Println(retries, "RETRYING! Error in fetching http:", err)
			time.Sleep(10 * time.Second)
		}
		retries = retries - 1

	}

	if err != nil {
		fmt.Println(err)
		return
	}

	if retries < 14 {
		c := color.New(color.FgGreen)
		c.Printf("\nRecovered from http error in %d tries\n", 14-retries)
	}
	return
}
Esempio n. 17
0
func boolToColor(b bool) *color.Color {
	if b {
		return color.New(color.FgGreen)
	} else {
		return color.New(color.FgHiRed)
	}
}
Esempio n. 18
0
func main() {
	red := color.New(color.FgRed).SprintFunc()
	green := color.New(color.FgGreen).SprintFunc()
	t1 := time.Now()
	fmt.Printf("START: %s\n", time.Now().UTC().Format(time.RFC3339))

	for i := 0; i < Threads; i++ {
		go hitEsearch()
	}
	for i := 0; i < Threads; i++ {
		<-c // wait for one task to complete
	}
	fmt.Printf("Complete: %v\n", perf)

	t2 := time.Now()

	duration := t2.Sub(t1)
	s := duration.String()
	dur, _ := time.ParseDuration("300ms")
	if t2.Sub(t1) > dur {
		s = red(s)
	} else {
		s = green(s)
	}
	total := Threads * Requests
	num := int(total) / int(duration.Seconds())
	fmt.Printf("END: %s -- %s %d Requests %d Requests/Second\n",
		time.Now().UTC().Format(time.RFC3339), s, total, num)
}
Esempio n. 19
0
// mainList - is a handler for mc ls command
func mainList(ctx *cli.Context) {
	checkListSyntax(ctx)

	args := ctx.Args()
	// Operating system tool behavior
	if globalMimicFlag && !ctx.Args().Present() {
		args = []string{"."}
	}

	console.SetCustomTheme(map[string]*color.Color{
		"File": color.New(color.FgWhite),
		"Dir":  color.New(color.FgCyan, color.Bold),
		"Size": color.New(color.FgYellow),
		"Time": color.New(color.FgGreen),
	})

	targetURLs, err := args2URLs(args)
	fatalIf(err.Trace(args...), "One or more unknown URL types passed.")

	for _, targetURL := range targetURLs {
		// if recursive strip off the "..."
		var clnt client.Client
		clnt, err = target2Client(stripRecursiveURL(targetURL))
		fatalIf(err.Trace(targetURL), "Unable to initialize target ‘"+targetURL+"’.")

		err = doList(clnt, isURLRecursive(targetURL), len(targetURLs) > 1)
		fatalIf(err.Trace(clnt.URL().String()), "Unable to list target ‘"+clnt.URL().String()+"’.")
	}
}
Esempio n. 20
0
func toColor(s interface{}, r RefType) string {
	if r == Hyperlink {
		return color.New(color.FgHiCyan).SprintFunc()(s)
	} else {
		return color.New(color.FgYellow).SprintFunc()(s)
	}
}
Esempio n. 21
0
func (this *ProbeResult) Summary() string {

	red := color.New(color.FgRed).SprintfFunc()
	yellow := color.New(color.FgYellow).SprintfFunc()
	green := color.New(color.FgGreen).SprintfFunc()

	// Name
	summary := "Probe " + this.Name + " : \n\n"

	// Print status
	summary += " Status 	: "
	if this.Status >= 300 {
		summary += red(strconv.Itoa(this.Status)) + "\n"
	} else if this.Status >= 200 {
		summary += yellow(strconv.Itoa(this.Status)) + "\n"
	} else {
		summary += green(strconv.Itoa(this.Status)) + "\n"
	}

	// Message
	summary += " Message 	: " + this.Message + "\n"
	summary += " Last execution	: " + this.ProbeDate + "\n\n"

	// Detail
	if this.Detail != nil {
		summary += " Detail : \n"
		summary += ToJson(this.Detail) + "\n\n"
	}

	return summary
}
Esempio n. 22
0
File: main.go Progetto: museun/ircp
func main() {
	flag.Parse()

	stop := make(chan os.Signal, 1)
	signal.Notify(stop, os.Kill, os.Interrupt)

	red := color.New(color.FgRed).SprintFunc()
	green := color.New(color.FgGreen).SprintFunc()

	lin, lout := listen(*inAddr)
	pin, pout := proxy(*outAddr)

	go func() {
		for data := range lout {
			fmt.Println(red(">>"), pretty(data))
			pin <- data
		}
	}()

	go func() {
		for data := range pout {
			fmt.Println(green("<<"), pretty(data))
			lin <- data
		}
	}()

	<-stop
}
Esempio n. 23
0
// PrettyString returns RockerImageData as a printable string
func (data *RockerImageData) PrettyString() string {
	prettyVars, err := json.MarshalIndent(data.Vars, "", "  ")
	if err != nil {
		log.Fatal(err)
	}
	prettyProps, err := json.MarshalIndent(data.Properties, "", "  ")
	if err != nil {
		log.Fatal(err)
	}
	green := color.New(color.FgGreen).SprintfFunc()
	yellow := color.New(color.FgYellow).SprintfFunc()
	sep := "=======================================================\n"

	res := fmt.Sprintf("%s%s\n", green(sep),
		green("Image: %s", data.ImageName.String()))

	if !data.Created.IsZero() {
		res = fmt.Sprintf("%sCreated: %s\n", res, data.Created.Format(time.RFC850))
	}

	if data.Properties != nil {
		res = fmt.Sprintf("%sProperties: %s\n", res, prettyProps)
	}

	if data.Vars != nil {
		res = fmt.Sprintf("%sVars: %s\n", res, prettyVars)
	}

	if data.Rockerfile != "" {
		res = fmt.Sprintf("%s%s\n%s\n%s\n%s", res, yellow("Rockerfile:"), yellow(sep), data.Rockerfile, yellow(sep))
	}

	return res
}
Esempio n. 24
0
// mainDiff main for 'diff'.
func mainDiff(ctx *cli.Context) {
	checkDiffSyntax(ctx)

	// Additional command speific theme customization.
	console.SetColor("DiffMessage", color.New(color.FgGreen, color.Bold))
	console.SetColor("DiffOnlyInFirst", color.New(color.FgRed, color.Bold))
	console.SetColor("DiffType", color.New(color.FgYellow, color.Bold))
	console.SetColor("DiffSize", color.New(color.FgMagenta, color.Bold))

	config := mustGetMcConfig()
	firstArg := ctx.Args().First()
	secondArg := ctx.Args().Last()

	firstURL := getAliasURL(firstArg, config.Aliases)
	secondURL := getAliasURL(secondArg, config.Aliases)

	newFirstURL := stripRecursiveURL(firstURL)
	for diff := range doDiffMain(newFirstURL, secondURL, isURLRecursive(firstURL)) {
		if diff.Error != nil {
			// Print in new line and adjust to top so that we don't print over the ongoing scan bar
			if !globalQuietFlag && !globalJSONFlag {
				console.Eraseline()
			}
		}
		fatalIf(diff.Error.Trace(newFirstURL, secondURL), "Failed to diff ‘"+firstURL+"’ and ‘"+secondURL+"’.")
		printMsg(diff)
	}
	// Print in new line and adjust to top so that we don't print over the ongoing scan bar
	if !globalQuietFlag && !globalJSONFlag {
		console.Eraseline()
	}
	console.Println(console.Colorize("DiffMessage", "Done."))
}
Esempio n. 25
0
//NewFormatter constructor
func NewFormatter() Formatter {
	yellow := color.New(color.FgYellow).SprintFunc()
	blue := color.New(color.FgBlue, color.Bold).SprintFunc()
	red := color.New(color.FgRed, color.Bold).SprintFunc()
	green := color.New(color.FgGreen, color.Bold).SprintFunc()
	formatter := Formatter{blue, yellow, red, green}
	return formatter
}
Esempio n. 26
0
File: mount.go Progetto: ovh/svfs
func setDebug() {
	logrus.SetLevel(logrus.DebugLevel)
	yellow := color.New(color.FgYellow).SprintFunc()
	blue := color.New(color.FgBlue).SprintFunc()
	fuse.Debug = func(msg interface{}) {
		logrus.WithField("source", yellow("fuse")).Debugln(blue(msg))
	}
}
Esempio n. 27
0
// colorizeUpdateMessage - inspired from Yeoman project npm package https://github.com/yeoman/update-notifier
func colorizeUpdateMessage(updateString string) (string, *probe.Error) {
	// TODO - make this configurable
	//
	// initialize coloring
	blue := color.New(color.FgBlue, color.Bold).SprintFunc()
	yellow := color.New(color.FgYellow, color.Bold).SprintfFunc()

	// calculate length without color coding, due to ANSI color characters padded to actual
	// string the final length is wrong than the original string length
	line1Str := fmt.Sprintf("  Update available: ")
	line2Str := fmt.Sprintf("  Run \"%s\" to update. ", updateString)
	line1Length := len(line1Str)
	line2Length := len(line2Str)

	// populate lines with color coding
	line1InColor := line1Str
	line2InColor := fmt.Sprintf("  Run \"%s\" to update. ", blue(updateString))

	// calculate the rectangular box size
	maxContentWidth := int(math.Max(float64(line1Length), float64(line2Length)))
	line1Rest := maxContentWidth - line1Length
	line2Rest := maxContentWidth - line2Length

	terminal, err := ts.GetSize()
	if err != nil {
		return "", probe.NewError(err)
	}

	var message string
	switch {
	case len(line2Str) > terminal.Col():
		message = "\n" + line1InColor + "\n" + line2InColor + "\n"
	default:
		// on windows terminal turn off unicode characters
		var top, bottom, sideBar string
		if runtime.GOOS == "windows" {
			top = yellow("*" + strings.Repeat("*", maxContentWidth) + "*")
			bottom = yellow("*" + strings.Repeat("*", maxContentWidth) + "*")
			sideBar = yellow("|")
		} else {
			// color the rectangular box, use unicode characters here
			top = yellow("┏" + strings.Repeat("━", maxContentWidth) + "┓")
			bottom = yellow("┗" + strings.Repeat("━", maxContentWidth) + "┛")
			sideBar = yellow("┃")
		}
		// fill spaces to the rest of the area
		spacePaddingLine1 := strings.Repeat(" ", line1Rest)
		spacePaddingLine2 := strings.Repeat(" ", line2Rest)

		// construct the final message
		message = "\n" + top + "\n" +
			sideBar + line1InColor + spacePaddingLine1 + sideBar + "\n" +
			sideBar + line2InColor + spacePaddingLine2 + sideBar + "\n" +
			bottom + "\n"
	}
	// finally print the message
	return message, nil
}
Esempio n. 28
0
// NewLogString creates a new LogString, and initializes color printing.
func NewLogString() *LogString {
	ls := new(LogString)
	ls.color = make(map[string]func(...interface{}) string)
	ls.color["red"] = color.New(color.FgRed).SprintFunc()
	ls.color["green"] = color.New(color.FgGreen).SprintFunc()
	ls.color["blue"] = color.New(color.FgBlue).SprintFunc()
	ls.color["yellow"] = color.New(color.FgYellow).SprintFunc()
	return ls
}
Esempio n. 29
0
func NewBash() *Bash {
	return &Bash{
		White:   color.New(color.FgWhite).SprintFunc(),
		Yellow:  color.New(color.FgYellow).SprintFunc(),
		Green:   color.New(color.FgGreen).SprintFunc(),
		Blue:    color.New(color.FgBlue).SprintFunc(),
		HiWrite: color.New(color.FgBlack, color.BgGreen).SprintFunc(),
	}
}
Esempio n. 30
0
func main() {
	boldCyan = color.New(color.FgCyan).Add(color.Bold)
	boldWhite = color.New(color.FgWhite).Add(color.Bold)

	cwd, _ = filepath.Abs(filepath.Dir(os.Args[0]))

	app := cli.NewApp()
	app.Name = "gut"
	app.Usage = "tool that retrieves templates and compile them to scaffold projects and create standalone files"
	app.Version = version
	app.Author = "Federico Carrone"
	app.Email = "*****@*****.**"

	app.Commands = []cli.Command{
		{
			Name:    "search",
			Aliases: []string{"s"},
			Usage:   "search templates",
			Action: func(c *cli.Context) {
				filter := c.Args().First()
				search(filter)
			},
		},
		{
			Name:    "new",
			Aliases: []string{"n"},
			Usage:   "new",
			Action: func(c *cli.Context) {
				if len(c.Args()) < 2 {
					fmt.Print("Not enough arguments")
				}
				templateName := c.Args().First()
				name = c.Args()[1]
				new(templateName)
			},
		},
		{
			Name:    "describe",
			Aliases: []string{"d"},
			Usage:   "describe",
			Action: func(c *cli.Context) {
				templateName := c.Args().First()
				describe(templateName)
			},
		},
		{
			Name:    "version",
			Aliases: []string{"v"},
			Usage:   "version",
			Action: func(c *cli.Context) {
				fmt.Printf("gut version %s\n", version)
			},
		},
	}

	app.Run(os.Args)
}