cli

package
v1.7.5 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RFC3339NanoFixed  = "2006-01-02T15:04:05.000000000Z07:00"
	RFC3339MilliFixed = "2006-01-02T15:04:05.000Z07:00"
)

Variables

View Source
var Module = fx.Module(
	"rig-cli",
	clientModule,
	fx.Provide(scheme.New),
	fx.Provide(func() (*cmdconfig.Config, error) {
		return cmdconfig.NewConfig("")
	}),
	fx.Provide(zap.NewDevelopment),
	fx.Provide(getContext),
	fx.Provide(func(c *cmdconfig.Context) *cmdconfig.Auth {
		return c.GetAuth()
	}),
	fx.Provide(func(c *cmdconfig.Context) *cmdconfig.Service {
		return c.GetService()
	}),
	fx.Provide(func() context.Context { return context.Background() }),
	fx.Provide(func() (*client.Client, error) {
		return client.NewClientWithOpts(
			client.WithHostFromEnv(),
			client.WithAPIVersionNegotiation(),
		)
	}),
	fx.Provide(func() *PromptInformation { return &PromptInformation{} }),
)

Functions

func AddOptions

func AddOptions(opts ...fx.Option)

func ExecuteInvokes

func ExecuteInvokes(cmd *cobra.Command, args []string, invokes ...any) error

func InvokePreRunE

func InvokePreRunE(cmd *cobra.Command, args []string, invokes ...any) error

IvokePreRunE registers FX invokes to be executed at the time a corresponding PreRunE would have been executed by Cobra had we not used FX.

func MakeInvokePreRunE

func MakeInvokePreRunE(invokes ...any) func(cmd *cobra.Command, args []string) error

MakeInvokePreRunE constructs a PreRunE function signature which registers the supplied invokes to be executed at the time Cobra would have executed the returned PreRunE if we did not use FX at all.

func PersistentPreRunE

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

PersistentPreRunE solves the issue described at the top of the file. It assumes all PreRunEs on the command chain has been wrapped in FX invokes and registered using InvokePreRunE. When Cobra starts executing PreRunEs, the following happens: If the current PreRunE being executed is not the last one, we simply do nothing. If the current PreRunE is the last one in the chain, we call FX to build all dependencies and run all Invokes. It is only this point we know exactly which dependencies are needed. It is assumed the Cobra main Run function has had its dependencies initialized by one of the Invokes registered.

func SkipFX

func SkipFX(cmd *cobra.Command) bool

Types

type F

type F = func(cmd *cobra.Command, args []string) error

func CtxWrap

func CtxWrap(f FCtx) F

type FComplete

type FComplete = func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective)

func CtxWrapCompletion

func CtxWrapCompletion(f FCompleteCtx) FComplete

type FCompleteCtx

type FCompleteCtx = func(context.Context, *cobra.Command, []string, string) ([]string, cobra.ShellCompDirective)

type FCtx

type FCtx = func(ctx context.Context, cmd *cobra.Command, args []string) error

type Interactive

type Interactive bool

type PromptInformation

type PromptInformation struct {
	ContextCreation bool
}

Jump to

Keyboard shortcuts

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