fncobra

package
v0.0.131 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2023 License: Apache-2.0 Imports: 101 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckVersion added in v0.0.111

func CheckVersion(ctx context.Context) func()

func CmdWithEnv

func CmdWithEnv(cmd *cobra.Command, f func(context.Context, cfg.Context, []string) error) *cobra.Command

Deprecated, use "ParseEnv"/"FixedEnv" instead.

func ConsoleToSink

func ConsoleToSink(out *os.File, isTerm bool) (tasks.ActionSink, colors.Style, func())

func DoMain

func DoMain(name string, registerCommands func(*cobra.Command))

func ListenPProf

func ListenPProf(debugSink io.Writer)

func RegisterPprof

func RegisterPprof(r *mux.Router)

func RunE

func RunE(handler CmdHandler) func(*cobra.Command, []string) error

func RunInContext added in v0.0.111

func RunInContext(ctx context.Context, handler func(context.Context) error, starter func(context.Context) func()) error

func SetupContext added in v0.0.84

func SetupContext(ctx context.Context) (context.Context, colors.Style, func())

func SetupViper

func SetupViper()

func StandardConsole

func StandardConsole() (*os.File, bool)

func With added in v0.0.84

func With(cmd *cobra.Command, handler func(context.Context) error) *cobra.Command

func WithSigIntCancel

func WithSigIntCancel(ctx context.Context) (context.Context, func())

Types

type ArgsParser

type ArgsParser interface {
	AddFlags(*cobra.Command)
	Parse(ctx context.Context, args []string) error
}

func HardcodeEnv

func HardcodeEnv(envOut *cfg.Context, env string) ArgsParser

HardcodeEnv is a temporary facility to trigger context loading with a predefined environment name.

func ParseEnv

func ParseEnv(envOut *cfg.Context) ArgsParser

type CmdHandler

type CmdHandler func(context.Context, []string) error

type CommandCtrl

type CommandCtrl struct {
	// contains filtered or unexported fields
}

func Cmd

func Cmd(cmd *cobra.Command) *CommandCtrl

func (*CommandCtrl) Do

func (c *CommandCtrl) Do(handler func(context.Context) error) *cobra.Command

func (*CommandCtrl) DoWithArgs

func (c *CommandCtrl) DoWithArgs(handler CmdHandler) *cobra.Command

func (*CommandCtrl) With

func (c *CommandCtrl) With(argParser ...ArgsParser) *CommandCtrl

func (*CommandCtrl) WithFlags

func (c *CommandCtrl) WithFlags(f func(flags *pflag.FlagSet)) *CommandCtrl

type Locations

type Locations struct {
	Locs []fnfs.Location
	Refs []*schema.PackageRef
	Root *parsing.Root
	// Whether the user explicitly specified a list of locations.
	// If true, "All" can be not empty if "DefaultToAllWhenEmpty" is true
	UserSpecified bool
}

func ParseLocs added in v0.0.84

func ParseLocs(ctx context.Context, args []string, env *cfg.Context, opts ParseLocationsOpts) (*Locations, error)

type LocationsParser

type LocationsParser struct {
	// contains filtered or unexported fields
}

func ParseLocations

func ParseLocations(locsOut *Locations, env *cfg.Context, opts ...ParseLocationsOpts) *LocationsParser

func (*LocationsParser) AddFlags

func (p *LocationsParser) AddFlags(cmd *cobra.Command)

func (*LocationsParser) Parse

func (p *LocationsParser) Parse(ctx context.Context, args []string) error

type ParseLocationsOpts

type ParseLocationsOpts struct {
	// Verify that exactly one location is specified.
	RequireSingle bool
	// If true, and no locations are specified, then "workspace.ListSchemas" result is used.
	ReturnAllIfNoneSpecified bool
	// If true, package reference added to Refs
	SupportPackageRef bool
}

func MergeParseLocationOpts added in v0.0.84

func MergeParseLocationOpts(opts []ParseLocationsOpts) ParseLocationsOpts

type Servers

type Servers struct {
	Servers        planning.Servers
	SealedPackages pkggraph.SealedPackageLoader
}

type ServersParser

type ServersParser struct {
	// contains filtered or unexported fields
}

func ParseServers

func ParseServers(serversOut *Servers, env *cfg.Context, locs *Locations) *ServersParser

func (*ServersParser) AddFlags

func (p *ServersParser) AddFlags(cmd *cobra.Command)

func (*ServersParser) Parse

func (p *ServersParser) Parse(ctx context.Context, args []string) error

Jump to

Keyboard shortcuts

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