command

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2025 License: Apache-2.0 Imports: 6 Imported by: 3

README

Reusable Command Line Options*

*for spf13/cobra-based CLI tools

This repository contains reusable command line options that some of the carabiner-tools share.

This repo is in it's early days, we expect it to mature slowly but feel free to file issues or suggestions if you find it useful.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FlagConfig added in v0.2.0

type FlagConfig struct {
	Short string
	Long  string
	Help  string
}

FlagConfig holds the configuration of a flag

type KeyOptions

type KeyOptions struct {
	PublicKeyPaths []string
	// contains filtered or unexported fields
}

func (*KeyOptions) AddFlags

func (ko *KeyOptions) AddFlags(cmd *cobra.Command)

AddFlags adds the options flags to a command

func (*KeyOptions) Config added in v0.2.0

func (ko *KeyOptions) Config() *OptionsSetConfig

func (*KeyOptions) ParseKeys

func (ko *KeyOptions) ParseKeys() ([]key.PublicKeyProvider, error)

ParseKeys parses the key files and returns a slice of public key providers.

func (*KeyOptions) Validate added in v0.1.1

func (ko *KeyOptions) Validate() error

Verify checks the options. Key files are verified to check if they exist

type OptionsSet

type OptionsSet interface {
	AddFlags(*cobra.Command)
	Validate() error
	Config() *OptionsSetConfig
}

OptionsSet is an interface that defines the functions options set need to implement to make them reusable.

type OptionsSetConfig added in v0.2.0

type OptionsSetConfig struct {
	FlagPrefix string
	Flags      map[string]FlagConfig
}

OptionsSetConfig configures a flag

func (*OptionsSetConfig) HelpText added in v0.2.0

func (c *OptionsSetConfig) HelpText(id string) string

func (*OptionsSetConfig) LongFlag added in v0.2.0

func (c *OptionsSetConfig) LongFlag(id string) string

func (*OptionsSetConfig) ShortFlag added in v0.2.0

func (c *OptionsSetConfig) ShortFlag(id string) string

type OutputFile added in v0.2.0

type OutputFile struct {
	OutputPath string
	// contains filtered or unexported fields
}

func (*OutputFile) AddFlags added in v0.2.0

func (oo *OutputFile) AddFlags(cmd *cobra.Command)

AddFlags adds the options flags to a command

func (*OutputFile) Config added in v0.2.0

func (oo *OutputFile) Config() *OptionsSetConfig

func (*OutputFile) GetWriter added in v0.2.0

func (oo *OutputFile) GetWriter() (io.Writer, error)

func (*OutputFile) Validate added in v0.2.0

func (oo *OutputFile) Validate() error

Jump to

Keyboard shortcuts

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