cliutil

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cliutil holds the flags and helpers that several subcommands share: the settings file, the cluster choice, and the schema files.

Index

Constants

View Source
const ConfigFlag = "config"

ConfigFlag is the global --config flag. The root command declares it; every subcommand reads it through LoadSettings.

View Source
const OpsConfigFlag = "ops-config"

OpsConfigFlag is the global --ops-config flag: the YAML file of the operations commands (NATS contexts, protection rules, bot schedules).

Variables

This section is empty.

Functions

func ClientSettings

func ClientSettings(cmd *cli.Command) (*config.Settings, error)

ClientSettings loads the settings for a client command: quietly, and without requiring a cluster, since --server can replace it.

func ConnFlags

func ConnFlags() []cli.Flag

ConnFlags select the NATS server a client command talks to: a cluster from the settings file, or a server given on the command line.

func Dial

func Dial(c config.NATS) (*nats.Conn, error)

Dial connects to c and fails fast when the server cannot be reached: an interactive command must not wait silently for a server that is not there. After the first connect it reconnects without limit.

func LoadSettings

func LoadSettings(cmd *cli.Command, opts ...config.LoadOption) (*config.Settings, error)

LoadSettings loads the settings file that --config names. A file the operator named explicitly must exist.

func ResolveCluster

func ResolveCluster(cmd *cli.Command, settings *config.Settings) (config.NATS, error)

ResolveCluster returns the connection settings the flags select.

func RootFlags

func RootFlags() []cli.Flag

RootFlags returns the flags the root command declares for all subcommands.

func SchemaFlags

func SchemaFlags() []cli.Flag

SchemaFlags add schema files and the type header to a command.

Types

type Schemas

type Schemas struct {
	Config   config.Schemas
	Registry *schema.Registry
	Router   *schema.Router
}

Schemas is the loaded schema state of a command.

func LoadSchemas

func LoadSchemas(ctx context.Context, cmd *cli.Command, settings *config.Settings) (*Schemas, error)

LoadSchemas merges the settings' [schemas] with every --schemas file, in order, and loads the sources.

func (*Schemas) Chain

func (s *Schemas) Chain(force string, emitDefaults bool) codec.Chain

Chain returns the decoder chain: protobuf first, then the schemaless fallbacks.

func (*Schemas) Proto

func (s *Schemas) Proto(force string, emitDefaults bool) *codec.ProtoDecoder

Proto returns the protobuf decoder, with force as the type for every payload when set.

Jump to

Keyboard shortcuts

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