Documentation ¶
Index ¶
- Constants
- Variables
- func AddOptions(opts ...fx.Option)
- func ExecuteInvokes(cmd *cobra.Command, args []string, invokes ...any) error
- func InvokePreRunE(cmd *cobra.Command, args []string, invokes ...any) error
- func MakeInvokePreRunE(invokes ...any) func(cmd *cobra.Command, args []string) error
- func PersistentPreRunE(cmd *cobra.Command, args []string) error
- func SkipFX(cmd *cobra.Command) bool
- type F
- type FComplete
- type FCompleteCtx
- type FCtx
- type Interactive
- type PromptInformation
Constants ¶
const ( RFC3339NanoFixed = "2006-01-02T15:04:05.000000000Z07:00" RFC3339MilliFixed = "2006-01-02T15:04:05.000Z07:00" )
Variables ¶
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 InvokePreRunE ¶
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 ¶
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 ¶
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.
Types ¶
type FComplete ¶
func CtxWrapCompletion ¶
func CtxWrapCompletion(f FCompleteCtx) FComplete
type FCompleteCtx ¶
type Interactive ¶
type Interactive bool
type PromptInformation ¶
type PromptInformation struct {
ContextCreation bool
}