base

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeShutdownCh

func MakeShutdownCh() chan struct{}

MakeShutdownCh returns a channel that can be used for shutdown notifications for commands. This channel will send a message for every SIGINT or SIGTERM received.

Types

type Command

type Command struct {
	// Context is the base context for the command. It is up to commands to
	// utilize this context so that cancellation works in a timely manner.
	Context context.Context

	// Flags is the flag set for the command.
	Flags *flag.FlagSet

	// Log is the logger to use.
	Log hclog.Logger

	// ShutdownCh is a channel that can be used for shutdown notifications
	// for commands.
	ShutdownCh chan struct{}

	// UI is used to write to the CLI.
	UI cli.Ui
}

Command is a base collection of common logic and data embedded in all commands.

func NewCommand

func NewCommand(log hclog.Logger, ui cli.Ui) *Command

NewCommand returns a new instance of a base.Command type.

func (*Command) WaitForInterrupt

func (c *Command) WaitForInterrupt(shutdownFunc func()) int

WaitForInterrupt waits for an interrupt signal and runs a provided shutdown function. While the graceful shutdown is in progress, another interrupt can trigger a forced-shutdown and will immediately exit.

type FlagSet

type FlagSet struct {
	*flag.FlagSet
}

FlagSet is a wrapper around a flag set.

func NewFlagSet

func NewFlagSet(f *flag.FlagSet) *FlagSet

NewFlagSet creates a new flag set.

func (*FlagSet) Help

func (f *FlagSet) Help() string

Help generates usage text for a flag set.

Jump to

Keyboard shortcuts

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