cobraflags

package
v0.0.0-...-e73c711 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package cobraflags implements some Flag and Command addons. They are split into a seperate package to be able to move them to a sperate repository eventually.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCompletionCommand

func AddCompletionCommand(parent, root *cobra.Command) *cobra.Command

func AddDocumentationCommand

func AddDocumentationCommand(parent, root *cobra.Command) *cobra.Command

func AddGeneratorCommand

func AddGeneratorCommand(parent *cobra.Command) *cobra.Command

func CheckAll

func CheckAll(cmd *cobra.Command, args []string, checker ...func(*cobra.Command, []string) error) (err error)

CheckAll runs pre-run checks of all given checkers.

func Exclusive

func Exclusive(mode os.FileMode) func(name string) (*os.File, error)

Exclusive is a fileopener for FileFlag, which attempts to open the file for writing exclusively. I.e. it fails if the file already exists.

func NoArgs

func NoArgs(cmd *cobra.Command, args []string) (err error)

similar to cobra.NoArgs but returns more appropriate error string

func Readonly

func Readonly() func(name string) (*os.File, error)

Readonly is a fileopener for FileFlag, which opens an existing file readonly.

func Truncate

func Truncate(mode os.FileMode) func(name string) (*os.File, error)

Truncate is a fileopener for FileFlag, which truncates any exiting file or creates a new one if it does not exist.

Types

type DirFlag

type DirFlag struct {
	Dir   string
	Check func(cmd *cobra.Command, args []string) error
}

func AddDirFlag

func AddDirFlag(cmd *cobra.Command, flag, short, value, usage string) (df *DirFlag)

type FileFlag

type FileFlag struct {
	File *os.File
	Open func(cmd *cobra.Command, args []string) error
}

func AddFileFlag

func AddFileFlag(cmd *cobra.Command, flag, short, usage string,
	open func(string) (*os.File, error), fallback *os.File) (ff *FileFlag)

type Key32Flag

type Key32Flag struct {
	Key   *[32]byte
	File  string
	Check func(cmd *cobra.Command, args []string) error
}

func AddKey32Flag

func AddKey32Flag(cmd *cobra.Command, flag, short, defval, usage string, fallback *os.File) (kf *Key32Flag)

AddKey32Flag adds a flag to a command, which can either be a valid base64 string or a filename for a 32 byte key. Optionally reads from stdin.

Jump to

Keyboard shortcuts

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