cliargs

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package cliargs holds the argument-shape guards shared by the nebula-agent and nebula-mgmt entrypoints.

Go's flag package stops parsing at the first non-flag token and leaves the rest as operands. A command line with a typo where a subcommand or flag belongs therefore runs with every later flag silently dropped — `nebula-agent enrool --server URL --token TOK` used to park in standby without ever contacting the server, which reads as a server-side failure. Both binaries reject that shape without copying the unclassified value into diagnostics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Guard

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

Guard reports argument-shape errors for a single binary. The zero value is usable; New attaches the per-binary usage hint appended to every message.

func New

func New(helpHint string) Guard

New returns a Guard whose errors end with helpHint (e.g. "run `nebula-agent help` for usage"). An empty hint is omitted.

func (Guard) RejectPositional

func (g Guard) RejectPositional(fs *flag.FlagSet) error

RejectPositional fails when flag parsing left unconsumed operands. Commands that legitimately take an operand validate NArg themselves rather than calling this.

func (Guard) UnknownCommand

func (g Guard) UnknownCommand(kind string) error

UnknownCommand reports an unrecognized command word. kind names what was expected — "command", "host subcommand", "service action".

Jump to

Keyboard shortcuts

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