cmdutil

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: May 22, 2021 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package cmdutil provides utilities that are shared between multiple commands like flags, documentation helpers and errors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddOutputFlag added in v0.2.0

func AddOutputFlag(cmd *cobra.Command, p *string, allowedValues ...string)

AddOutputFlag adds the --output flag to cmd and binds it to p. The first value from allowedValues is set as the default. Panics if allowedValues is empty.

func AddRepositoryFlag added in v0.2.0

func AddRepositoryFlag(cmd *cobra.Command, f *Factory, p *[]string)

AddRepositoryFlag adds the --repository flag to cmd and binds it to p.

func ExactNonEmptyArgs added in v0.2.0

func ExactNonEmptyArgs(n int) cobra.PositionalArgs

ExactNonEmptyArgs returns an error if there are not exactly n args or if any of them is an empty string.

func Examples

func Examples(s string) string

Examples formats examples for a *cobra.Command. Each line is indented by 2 spaces so that it aligns nicely with usage and flags.

func GitignoreNames added in v0.2.0

func GitignoreNames(f *Factory) []string

GitignoreNames compiles a sorted list of gitignore template names. Used for completion.

func LicenseNames added in v0.2.0

func LicenseNames(f *Factory) []string

LicenseNames compiles a sorted list of license names. Used for completion.

func LogLevelNames added in v0.2.0

func LogLevelNames() []string

LogLevelNames compiles a list of log level names. Used for completion.

func LongDesc

func LongDesc(s string) string

LongDesc formats the long description for a *cobra.Command.

func RenderJSON

func RenderJSON(w io.Writer, v interface{}) error

RenderJSON converts v to JSON and writes it to w.

func RenderYAML

func RenderYAML(w io.Writer, v interface{}) error

RenderYAML converts v to YAML and writes it to w.

func RepositoryNames added in v0.2.0

func RepositoryNames(f *Factory) []string

RepositoryNames compiles a sorted list of repository names from the config. Used for completion.

func SkeletonFilenames added in v0.2.0

func SkeletonFilenames(f *Factory, skeletonName string, repoNames ...string) []string

SkeletonFilenames compiles a sorted list of skeleton file names from the configured repositories. Used for completion.

func SkeletonNames added in v0.2.0

func SkeletonNames(f *Factory, repoNames ...string) []string

SkeletonNames compiles a sorted list of skeleton names from the configured repositories. Used for completion.

Types

type Factory added in v0.2.0

type Factory struct {
	IOStreams  cli.IOStreams
	ConfigPath string
	Config     func() (*kickoff.Config, error)
	GitClient  func() git.Client
	HTTPClient func() *http.Client
	Repository func(...string) (kickoff.Repository, error)
	Prompt     prompt.Prompt
}

Factory can create instances of commonly needed datastructures like config, repository and http client.

func NewFactory added in v0.2.0

func NewFactory(ioStreams cli.IOStreams) *Factory

NewFactory creates the default *Factory that is passed to commands.

func NewFactoryWithConfigPath added in v0.2.0

func NewFactoryWithConfigPath(ioStreams cli.IOStreams, configPath string) *Factory

NewFactoryWithConfigPath creates the default *Factory that is passed to commands.

type RepositoryAlreadyExistsError added in v0.2.0

type RepositoryAlreadyExistsError string

func (RepositoryAlreadyExistsError) Error added in v0.2.0

Error implements the error interface.

type RepositoryNotConfiguredError added in v0.1.1

type RepositoryNotConfiguredError string

func (RepositoryNotConfiguredError) Error added in v0.1.1

Error implements the error interface.

Jump to

Keyboard shortcuts

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