buf: github.com/bufbuild/buf/internal/pkg/app/appcmd Index | Files | Directories

package appcmd

import "github.com/bufbuild/buf/internal/pkg/app/appcmd"

Package appcmd contains helper functionality for applications using commands.

Index

Package Files

appcmd.go error.go

func BindMultiple Uses

func BindMultiple(bindFuncs ...func(*pflag.FlagSet)) func(*pflag.FlagSet)

BindMultiple is a convenience function for binding multiple flag functions.

func Main Uses

func Main(ctx context.Context, command *Command)

Main runs the application using the OS container and calling os.Exit on the return value of Run.

func NewInvalidArgumentError Uses

func NewInvalidArgumentError(message string) error

NewInvalidArgumentError creates a new invalidArgumentError, indicating that the error was caused by argument validation. This causes us to print the usage help text for the command that it is returned from.

func NewInvalidArgumentErrorf Uses

func NewInvalidArgumentErrorf(format string, args ...interface{}) error

NewInvalidArgumentErrorf creates a new InvalidArgumentError, indicating that the error was caused by argument validation. This causes us to print the usage help text for the command that it is returned from.

func Run Uses

func Run(ctx context.Context, container app.Container, command *Command) error

Run runs the application using the container.

type Command Uses

type Command struct {
    // Use is the one-line usage message.
    // Required.
    Use string
    // Short is the short message shown in the 'help' output.
    // Required if Long is set.
    Short string
    // Long is the long message shown in the 'help <this-command>' output.
    // The Short field will be prepended to the Long field with two newlines.
    // Must be unset if short is unset.
    Long string
    // Args are the expected arguments.
    //
    // TODO: make specific types for appcmd to limit what can be done.
    Args cobra.PositionalArgs
    // Deprecated says to print this deprecation string.
    Deprecated string
    // Hidden says to hide this command.
    Hidden bool
    // BindFlags allows binding of flags on build.
    BindFlags func(*pflag.FlagSet)
    // BindPersistentFlags allows binding of flags on build.
    BindPersistentFlags func(*pflag.FlagSet)
    // NormalizeFlag allows for normalization of flag names.
    NormalizeFlag func(*pflag.FlagSet, string) string
    // NormalizePersistentFlag allows for normalization of flag names.
    NormalizePersistentFlag func(*pflag.FlagSet, string) string
    // Run is the command to run.
    // Required if there are no sub-commands.
    // Must be unset if there are sub-commands.
    Run func(context.Context, app.Container) error
    // Version is the version.
    Version string
    // SubCommands are the sub-commands. Optional.
    // Must be unset if there is a run function.
    SubCommands []*Command
}

Command is a command.

Directories

PathSynopsis
appcmdtesting

Package appcmd imports 7 packages (graph) and is imported by 1 packages. Updated 2020-10-20. Refresh now. Tools for package owners.