Files
QSfera/vendor/github.com/gookit/goutil/sysutil/cmdr/cmdr.go
T
dependabot[bot]andRalf Haferkamp 5ebc596352 Bump github.com/gookit/config/v2 from 2.1.8 to 2.2.2
Bumps [github.com/gookit/config/v2](https://github.com/gookit/config) from 2.1.8 to 2.2.2.
- [Release notes](https://github.com/gookit/config/releases)
- [Commits](https://github.com/gookit/config/compare/v2.1.8...v2.2.2)

---
updated-dependencies:
- dependency-name: github.com/gookit/config/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-13 10:54:58 +02:00

35 lines
670 B
Go

// Package cmdr Provide for quick build and run a cmd, batch run multi cmd tasks
package cmdr
import (
"strings"
"github.com/gookit/color"
)
// 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
}