cmdopts

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExitCodeOK int32 = iota
	ExitCodeConfigError
	ExitCodeCmdError
	ExitCodeWebUIError
	ExitCodeUpgradeError
	ExitCodeUserCancel
	ExitCodeShutdownCommand
	ExitCodeFatalError
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigCommand

type ConfigCommand struct {
	Init    ConfigInitCommand    `command:"init" description:"Initialize configuration"`
	Upgrade ConfigUpgradeCommand `command:"upgrade" description:"Upgrade configuration schema"`
	// contains filtered or unexported fields
}

func NewConfigCommand

func NewConfigCommand(owner *Options) *ConfigCommand

type ConfigInitCommand

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

func (*ConfigInitCommand) Execute

func (cmd *ConfigInitCommand) Execute([]string) error

func (*ConfigInitCommand) InitMetrics

func (cmd *ConfigInitCommand) InitMetrics()

func (*ConfigInitCommand) InitSources

func (cmd *ConfigInitCommand) InitSources()

type ConfigUpgradeCommand

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

func (*ConfigUpgradeCommand) Execute

func (cmd *ConfigUpgradeCommand) Execute([]string) (err error)

type Kind

type Kind int
const (
	ConfigPgURL Kind = iota
	ConfigFile
	ConfigFolder
	ConfigError
)

type MetricCommand

type MetricCommand struct {
	PrintInit MetricPrintInitCommand `command:"print-init" description:"Get and print init SQL for a given metric or preset"`
	PrintSQL  MetricPrintSQLCommand  `command:"print-sql" description:"Get and print SQL for a given metric"`
	// contains filtered or unexported fields
}

func NewMetricCommand

func NewMetricCommand(owner *Options) *MetricCommand

type MetricPrintInitCommand

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

func (*MetricPrintInitCommand) Execute

func (cmd *MetricPrintInitCommand) Execute(args []string) error

type MetricPrintSQLCommand

type MetricPrintSQLCommand struct {
	Version int `short:"v" long:"version" description:"PostgreSQL version to get SQL for"`
	// contains filtered or unexported fields
}

func (*MetricPrintSQLCommand) Execute

func (cmd *MetricPrintSQLCommand) Execute(args []string) error

type Options

type Options struct {
	Sources sources.CmdOpts   `group:"Sources"`
	Metrics metrics.CmdOpts   `group:"Metrics"`
	Sinks   sinks.CmdOpts     `group:"Sinks"`
	Logging log.CmdOpts       `group:"Logging"`
	WebUI   webserver.CmdOpts `group:"WebUI"`
	Help    bool

	// sourcesReaderWriter reads/writes the monitored sources (databases, patroni clusters, pgpools, etc.) information
	SourcesReaderWriter sources.ReaderWriter
	// metricsReaderWriter reads/writes the metric and preset definitions
	MetricsReaderWriter metrics.ReaderWriter
	ExitCode            int32
	CommandCompleted    bool
}

Options contains the command line options.

func New

func New(writer io.Writer) (cmdOpts *Options, err error)

New returns a new instance of Options and immediately executes the subcommand if specified. Errors are returned for parsing only, if the command line arguments are invalid. Subcommands execution errors (if any) do not affect error returned. Subcommands are responsible for setting exit code only.

func (*Options) CompleteCommand

func (c *Options) CompleteCommand(code int32)

func (*Options) GetConfigKind

func (c *Options) GetConfigKind(arg string) (_ Kind, err error)

func (*Options) InitConfigReaders

func (c *Options) InitConfigReaders(ctx context.Context) error

InitConfigReaders creates the configuration readers based on the configuration kind from the options.

func (*Options) InitMetricReader

func (c *Options) InitMetricReader(ctx context.Context) (err error)

InitMetricReader creates a new source reader based on the configuration kind from the options.

func (*Options) InitSourceReader

func (c *Options) InitSourceReader(ctx context.Context) (err error)

InitSourceReader creates a new source reader based on the configuration kind from the options.

func (*Options) InitWebUI

func (c *Options) InitWebUI(fs fs.FS, logger log.LoggerIface) error

InitWebUI initializes the web UI server

func (*Options) IsPgConnStr

func (c *Options) IsPgConnStr(arg string) bool

func (*Options) NeedsSchemaUpgrade

func (c *Options) NeedsSchemaUpgrade() (upgrade bool, err error)

NeedsSchemaUpgrade checks if the configuration database schema needs an upgrade.

func (*Options) Verbose

func (c *Options) Verbose() bool

Verbose returns true if the debug log is enabled

type SourceCommand

type SourceCommand struct {
	Ping SourcePingCommand `command:"ping" description:"Try to connect to configured sources, report errors if any and then exit"`
	// contains filtered or unexported fields
}

func NewSourceCommand

func NewSourceCommand(owner *Options) *SourceCommand

type SourcePingCommand

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

func (*SourcePingCommand) Execute

func (cmd *SourcePingCommand) Execute(args []string) error

Jump to

Keyboard shortcuts

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