You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
588 B
Go
33 lines
588 B
Go
package cmdr
|
|
|
|
import (
|
|
"github.com/gookit/color"
|
|
"strings"
|
|
)
|
|
|
|
// PrintCmdline on before exec
|
|
func PrintCmdline(c *Cmd) {
|
|
if c.DryRun {
|
|
color.Yellowln("DRY-RUN>", c.Cmdline())
|
|
} else {
|
|
color.Yellowln(">", c.Cmdline())
|
|
}
|
|
}
|
|
|
|
// OutputLines split output to lines
|
|
func OutputLines(output string) []string {
|
|
output = strings.TrimSuffix(output, "\n")
|
|
if output == "" {
|
|
return nil
|
|
}
|
|
return strings.Split(output, "\n")
|
|
}
|
|
|
|
// FirstLine from command output
|
|
func FirstLine(output string) string {
|
|
if i := strings.Index(output, "\n"); i >= 0 {
|
|
return output[0:i]
|
|
}
|
|
return output
|
|
}
|