Beispiel #1
0
func execute(path string, vcs string, vcs_verb string) {
	if vcs_verb == "" {
		return
	}
	a := func(wd string, vcs string, vcs_verb string, seq bool) {
		msg := "=== @{!" + vcs_color[vcs] + "} "
		msg += filepath.Base(path)
		msg += "@| (@!" + vcs + "@|) ==="
		var cmd exec.Cmd
		cmd.Dir = wd
		cmd.Args = strings.Split(vcs_verb, " ")
		path, err := exec.LookPath(cmd.Args[0])
		if err != nil {
			path = cmd.Args[0]
		}
		cmd.Path = path
		out, err := cmd.CombinedOutput()
		if err != nil {
			br := color.Colorize("!r")
			rst := color.Colorize("|")
			fmt.Printf(color.Sprint(msg)+"\n%s\n%s%s%s\n\n", out, br, err, rst)
		} else {
			fmt.Printf(color.Sprint(msg)+"\n%s\n", out)
		}
		if !seq {
			quit <- 0
		}
	}
	if *sequential {
		a(path, vcs, vcs_verb, *sequential)
	} else {
		count += 1
		go a(path, vcs, vcs_verb, *sequential)
	}
}
Beispiel #2
0
func highlightMatches(input string, offsets []MatchOffset) string {
	var list MatchList = offsets
	sort.Sort(list)

	output := ""
	offset := 0
	startMarker := color.Colorize("r!")
	endMarker := color.Colorize("|")

	for _, match := range list {
		if offset < match.Start {
			output += input[offset:match.Start]
		}
		output += startMarker
		output += input[match.Start : match.Start+match.Length]
		output += endMarker
		offset = match.Start + match.Length
	}
	output += input[offset:]

	return output
}
Beispiel #3
0
func (w *TerminalWriter) Color(syntax string) *TerminalWriter {
	escapeCode := color.Colorize(syntax)
	w.checkOutput(escapeCode)
	return w
}