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.
Index ¶
- Constants
- Variables
- func AttributeFlags(c *cobra.Command, obj any, args ...string)
- 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)
- 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 EnumFlag
- type FlagError
- type PersistentPreRunnable
- type PreRunnable
- type Runnable
Constants ¶
const AnnotationHelpGroup = "help:group"
AnnotationHelpGroup is used to indicate in which help group a command belongs.
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 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.