Beispiel #1
0
// Lines gives the entire output as a string slice, with each item in the slice
// representing one line of the output. Lines are determined by splitting the
// string on newline characters. Preceding and trailing empty lines are removed
// from the output, and each line is trimmed of whitespace.
func (o *Output) Lines() []string {
	lines := strings.Split(o.String(), "\n")
	for i, s := range lines {
		lines[i] = whitespace.Trim(s)
	}
	return lines
}
Beispiel #2
0
// Execute exists to present a helpful error to the user, in the case they just
// run 'sous' with not subcommand.
func (s *Sous) Execute(args []string) cmdr.Result {
	r := s.CLI.InvokeWithoutPrinting([]string{"sous", "help"})
	success, ok := r.(cmdr.SuccessResult)
	if !ok {
		return s.usage()
	}
	return UsageErrorf(whitespace.Trim(success.String()) + "\n")
}
Beispiel #3
0
// Lines returns Stdout split by newline. Leading and trailing empty lines are
// removed, and each line is trimmed of whitespace.
func (c *DummyCommand) Lines() ([]string, error) {
	stdout, err := c.Stdout()
	if err != nil {
		return nil, err
	}
	rawLines := strings.Split(stdout, "\n")
	lines := []string{}
	for _, l := range rawLines {
		trimmed := whitespace.Trim(l)
		if len(trimmed) == 0 {
			continue
		}
		lines = append(lines, trimmed)
	}
	return lines, nil
}
Beispiel #4
0
// String is gives the entire output as a string, with whitespace trimmed.
func (o *Output) String() string {
	return whitespace.Trim(o.buffer.String())
}
Beispiel #5
0
func (c *LocalSousConfig) String() string {
	// yaml marshaller adds a trailing newline
	return whitespace.Trim(string(c.Bytes()))
}