Documentation ¶
Overview ¶
SPDX-License-Identifier: MIT Copyright (c) 2019, 2019 GitHub Inc. Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. Licensed under the MIT License (the "License"). You may not use this file expect in compliance with the License.
SPDX-License-Identifier: Apache-2.0 Copyright 2022 Acorn Labs, Inc; All rights reserved. Copyright 2022 Unikraft GmbH; All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
SPDX-License-Identifier: MIT Copyright (c) 2019 GitHub Inc. Copyright (c) 2022 Unikraft GmbH.
SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2012 Alex Ogier. Copyright (c) 2012 The Go Authors. Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. Licensed under the BSD-3-Clause License (the "License"). You may not use this file except in compliance with the License.
SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2012 Alex Ogier. Copyright (c) 2012 The Go Authors. Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. Licensed under the BSD-3-Clause License (the "License"). You may not use this file except in compliance with the License.
SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. Licensed under the BSD-3-Clause License (the "License"). You may not use this file expect in compliance with the License.
SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2012 Alex Ogier. Copyright (c) 2012 The Go Authors. Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. Licensed under the BSD-3-Clause License (the "License"). You may not use this file except in compliance with the License.
SPDX-License-Identifier: MIT Copyright (c) 2019 GitHub Inc. Copyright (c) 2022 Unikraft GmbH.
SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. Licensed under the BSD-3-Clause License (the "License"). You may not use this file except in compliance with the License.
Index ¶
- Variables
- func AttributeFlags(c *cobra.Command, obj any)
- func BoolVar(p *bool, name string, value bool, usage string) *pflag.Flag
- func BoolVarP(p *bool, name, shorthand string, value bool, usage string) *pflag.Flag
- func ExactArgs(n int, msg string) cobra.PositionalArgs
- func FlagErrorWrap(err error) error
- func FlagErrorf(format string, args ...interface{}) error
- func HasFailed() bool
- func IsUserCancellation(err error) bool
- func Main(ctx context.Context, cmd *cobra.Command, opts ...CliOption)
- func MaxDirArgs(n int) cobra.PositionalArgs
- func MinimumArgs(n int, msg string) cobra.PositionalArgs
- func MutuallyExclusive(message string, conditions ...bool) error
- func Name(obj any) string
- func New(obj Runnable, cmd cobra.Command) *cobra.Command
- func NoArgsQuoteReminder(cmd *cobra.Command, args []string) error
- func RegisterFlag(cmdline string, flag *pflag.Flag)
- func StringVar(p *string, name string, value string, usage string) *pflag.Flag
- func StringVarP(p *string, name, shorthand string, value string, usage string) *pflag.Flag
- func VarF(value pflag.Value, name, usage string) *pflag.Flag
- func VarPF(value pflag.Value, name, shorthand, usage string) *pflag.Flag
- type CliOption
- func WithConfigManager(cfgm *config.ConfigManager) CliOption
- func WithDefaultConfigManager(cmd *cobra.Command) CliOption
- func WithDefaultHTTPClient() CliOption
- func WithDefaultIOStreams() CliOption
- func WithDefaultLogger() CliOption
- func WithDefaultPackageManager() CliOption
- func WithDefaultPluginManager() CliOption
- func WithHTTPClient(httpClient *http.Client) CliOption
- func WithIOStreams(io *iostreams.IOStreams) CliOption
- func WithPackageManager(pm packmanager.PackageManager) CliOption
- func WithPluginManager(pm *plugins.PluginManager) CliOption
- type CliOptions
- type EnumFlag
- type FlagError
- type PersistentPreRunnable
- type PreRunnable
- type Runnable
Constants ¶
This section is empty.
Variables ¶
var ErrCancel = errors.New("ErrCancel")
ErrCancel signals user-initiated cancellation
var ErrSilent = errors.New("ErrSilent")
ErrSilent is an error that triggers exit code 1 without any error messaging
Functions ¶
func AttributeFlags ¶ added in v0.4.0
AttributeFlags associates a given struct with public attributes and a set of tags with the provided cobra command so as to enable dynamic population of CLI flags.
func BoolVar ¶ added in v0.4.0
BoolVar returns an instantiated flag for to an associated pointer boolean value with a given name, default value and usage line.
func BoolVarP ¶
BoolVarP is like BoolVar, but accepts a shorthand letter that can be used after a single dash.
func FlagErrorWrap ¶
FlagError returns a new FlagError that wraps the specified error.
func FlagErrorf ¶
FlagErrorf returns a new FlagError that wraps an error produced by fmt.Errorf(format, args...).
func HasFailed ¶
func HasFailed() bool
HasFailed signals that the main process should exit with non-zero status
func IsUserCancellation ¶
func MaxDirArgs ¶
func MaxDirArgs(n int) cobra.PositionalArgs
func MinimumArgs ¶
func MinimumArgs(n int, msg string) cobra.PositionalArgs
func MutuallyExclusive ¶
func New ¶
New populates a cobra.Command object by extracting args from struct tags of the Runnable obj passed. Also the Run method is assigned to the RunE of the command. name = Override the struct field with
func RegisterFlag ¶
func StringVar ¶ added in v0.4.0
StringVar returns an instantiated flag for to an associated pointer string value with a given name, default value and usage line.
func StringVarP ¶
StringVarP is like StringVar, but accepts a shorthand letter that can be used after a single dash.
Types ¶
type CliOption ¶
type CliOption func(*CliOptions) error
func WithConfigManager ¶
func WithConfigManager(cfgm *config.ConfigManager) CliOption
WithConfigManager sets a previously instantiate ConfigManager to be used as part of the CLI options.
func WithDefaultConfigManager ¶
WithDefaultConfigManager instantiates a configuration manager based on default options.
func WithDefaultHTTPClient ¶
func WithDefaultHTTPClient() CliOption
WithDefaultHTTPClient initializes a HTTP client using host-provided configuration.
func WithDefaultIOStreams ¶
func WithDefaultIOStreams() CliOption
WithDefaultIOStreams instantiates ta new IO streams using environmental variables and host-provided configuration.
func WithDefaultLogger ¶
func WithDefaultLogger() CliOption
WithDefaultLogger sets up the built in logger based on provided conifg found from the ConfigManager.
func WithDefaultPackageManager ¶
func WithDefaultPackageManager() CliOption
WithDefaultPackageManager initializes a new package manager based on the umbrella package manager using host-provided configuration.
func WithDefaultPluginManager ¶
func WithDefaultPluginManager() CliOption
WithDefaultPluginManager returns an initialized plugin manager using the host-provided configuration plugin path.
func WithHTTPClient ¶
WithHTTPClient sets a previously instantiated http.Client to be used within the command.
func WithIOStreams ¶
WithIOStreams sets a previously instantiated iostreams.IOStreams structure to be used within the command.
func WithPackageManager ¶
func WithPackageManager(pm packmanager.PackageManager) CliOption
WithPackageManager sets a previously initialized package manager to be used with the command.
func WithPluginManager ¶
func WithPluginManager(pm *plugins.PluginManager) CliOption
WithPluginManager sets a previously instantiated plugin manager to be used withthe command.
type CliOptions ¶
type CliOptions struct {
// contains filtered or unexported fields
}
type EnumFlag ¶
func NewEnumFlag ¶
NewEnumFlag give a list of allowed flag parameters, where the second argument is the default
type FlagError ¶
type FlagError struct {
// contains filtered or unexported fields
}
A *FlagError indicates an error processing command-line flags or other arguments. Such errors cause the application to display the usage message.