Index | Files

package split

import ""

Package split provides a module that splits the output from an existing module and sends it to two new modules. This can be useful for modules that display a lot of information, by allowing some of the module output to be placed elsewhere, typically somewhere in a group that only shows it when requested.

For example, an email module may support multiple folders, so it could be configured to output one segment per folder, inbox coming first. It can then be split at 1, to provide a summary for just inbox, and a detail for all other folders, with the detail module placed in a collapsible group.

labels := []string{"INBOX", "OUTBOX", "To-Do", "Follow-Up"}
mail := mailProvider.New(labels...).
	Output(func(m mailProvider.Info) bar.Output {
		o := outputs.Group()
		for _, lbl := range labels {
			o.Append(outputs.Textf("%d", m[lbl]))
		return o
inbox, others := split.SplitModule(mail, 1)


Package Files


func New Uses

func New(original bar.Module, n int) (first, rest bar.Module)

New splits the output from a module at index n, and returns two modules. The first module displays segments 0 through n (inclusive), while the second module displays all remaining segments. One or both of the modules will show an empty output if there are not enough segments in the original output.

Package split imports 5 packages (graph) and is imported by 1 packages. Updated 2018-11-25. Refresh now. Tools for package owners.