Help us shape the future of Go! Take the 2026 Go Developer Survey

internal

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SkipVersionCheckFlag = NewFlagForSetting[bool]("skip-version-check", setting.SkipVersionCheck)
	EndpointFlag         = NewFlagForSetting[string]("endpoint", setting.Endpoint)
	WorkspaceFlag        = NewFlagForSetting[string]("workspace", setting.Workspace)
	ProfileFlag          = NewFlagForSetting[string]("profile", setting.Profile)
)
View Source
var Version = devVersion

Version identifies the CLI to the meshStack API through the client's UserAgent. A release overrides it with -ldflags "-X github.com/meshcloud/meshstack-cli/cmd/internal.Version=<tag>".

Functions

func CutShortNote added in v0.2.0

func CutShortNote(limit, listed int, total *int, defaulted bool) string

CutShortNote says that a listing stopped at its limit before the end, and is empty for a listing that is complete.

func First added in v0.2.0

func First[T any](items iter.Seq2[T, error], n int) iter.Seq2[T, error]

func ListWorkspace added in v0.2.0

func ListWorkspace(ctx context.Context) (*string, error)

ListWorkspace is the workspace a listing is narrowed to, or nil for none. It leaves out the profile's default workspace, so that a listing asked for no workspace shows what the credential can see.

func ResolveClient

func ResolveClient(ctx context.Context) (client.Client, error)

ResolveClient is the only place a client is built, so every command sends the same user agent and resolves the same global flags as settings.

func ResolveClientOptions added in v0.2.0

func ResolveClientOptions() auth.ResolveClientOptions

func SettingSources

func SettingSources() setting.Sources

func WriteList added in v0.2.0

func WriteList(w io.Writer, format OutputFormat, items iter.Seq2[jsontext.Value, error]) error

WriteList leaves a listing that fails part way through unterminated, so that json output which stopped early does not parse as a complete array.

Types

type Flag

type Flag[T string | bool] struct {
	Name  FlagName
	Help  string
	Value T
	// SettingEnvKey is required to use the Flag as a setting.FrontendSource.
	SettingEnvKey string
}

func NewFlagForSetting

func NewFlagForSetting[T string | bool](name FlagName, s setting.Setting) Flag[T]

func (*Flag[T]) AsSource

func (flag *Flag[T]) AsSource() setting.FrontendSource

func (*Flag[T]) AsSourceUnless

func (flag *Flag[T]) AsSourceUnless(predicate func(T) bool) setting.FrontendSource

AsSourceUnless contributes nothing but its own name while the flag still carries the placeholder. The source is registered anyway, so setting resolution can name it in its error.

func (*Flag[T]) Register

func (flag *Flag[T]) Register(flags *pflag.FlagSet) (flagName string)

type FlagName

type FlagName string

func (FlagName) SourceDescription

func (n FlagName) SourceDescription() string

func (FlagName) String

func (n FlagName) String() string

type LimitFlag added in v0.2.0

type LimitFlag int

func (*LimitFlag) Set added in v0.2.0

func (f *LimitFlag) Set(value string) error

func (*LimitFlag) String added in v0.2.0

func (f *LimitFlag) String() string

func (*LimitFlag) Type added in v0.2.0

func (f *LimitFlag) Type() string

type ListFlags added in v0.2.0

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

ListFlags are the flags every list command takes, and Run is how each one lists.

func (*ListFlags) Register added in v0.2.0

func (f *ListFlags) Register(flags *pflag.FlagSet)

func (*ListFlags) Run added in v0.2.0

func (f *ListFlags) Run(cmd *cobra.Command, list func(ctx context.Context, meshStack client.Client) iter.Seq2[jsontext.Value, error]) error

type OutputFlag added in v0.2.0

type OutputFlag struct{ Format OutputFormat }

OutputFlag registers --output and holds what it was set to. It implements pflag.Value, so an unknown format is rejected while the flags are parsed rather than after the first page arrived.

func (*OutputFlag) Register added in v0.2.0

func (f *OutputFlag) Register(flags *pflag.FlagSet)

func (*OutputFlag) Set added in v0.2.0

func (f *OutputFlag) Set(value string) error

func (*OutputFlag) String added in v0.2.0

func (f *OutputFlag) String() string

func (*OutputFlag) Type added in v0.2.0

func (f *OutputFlag) Type() string

type OutputFormat added in v0.2.0

type OutputFormat string

OutputFormat is what a list command writes its items as.

const (
	OutputJson   OutputFormat = "json"
	OutputNdjson OutputFormat = "ndjson"
)

Jump to

Keyboard shortcuts

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