shell

package
Version: v0.0.0-...-f1791b3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2022 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Overview

Package shell provides modules to display the output of shell commands. It supports both long-running commands, where the output is the last line, e.g. dmesg or tail -f /var/log/some.log, and repeatedly running commands, e.g. whoami, date +%s.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Module

type Module struct {
	// contains filtered or unexported fields
}

Module represents a shell module that updates on a timer or on demand.

func New

func New(cmd string, args ...string) *Module

New constructs a new shell module.

func (*Module) Every

func (m *Module) Every(interval time.Duration) *Module

Every sets the refresh interval for the module. The command will be executed repeatedly at the given interval, and the output updated. A zero interval stops automatic repeats (but Refresh will still work).

func (*Module) Output

func (m *Module) Output(format func(string) bar.Output) *Module

Output sets the output format. The format func will be passed the entire trimmed output from the command once it's done executing. To process output by lines, see Tail().

func (*Module) Refresh

func (m *Module) Refresh()

Refresh executes the command and updates the output.

func (*Module) Stream

func (m *Module) Stream(s bar.Sink)

Stream starts the module.

type TailModule

type TailModule struct {
	// contains filtered or unexported fields
}

TailModule represents a bar.Module that displays the last line of output from a shell command in the bar.

func Tail

func Tail(cmd string, args ...string) *TailModule

Tail constructs a module that displays the last line of output from a long running command.

func (*TailModule) Output

func (m *TailModule) Output(format func(string) bar.Output) *TailModule

Output sets the output format for each line of output.

func (*TailModule) Stream

func (m *TailModule) Stream(s bar.Sink)

Stream starts the module.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL