Documentation ¶
Index ¶
- Constants
- Variables
- func GetClientOptions(scope scope.Scope) ([]rig.Option, error)
- func MakeTestModule(i TestModuleInput) fx.Option
- func SkipFX(cmd *cobra.Command) bool
- type ContextDependency
- type F
- type FComplete
- type FCompleteCtx
- type FCompleteCtxSetup
- type FCompleteSetup
- type FCtx
- type PromptInformation
- type SetupContext
- func (s *SetupContext) AddOptions(opts ...fx.Option)
- func (s *SetupContext) ExecuteInvokes(cmd *cobra.Command, args []string, invokes ...any) error
- func (s *SetupContext) InvokePreRunE(cmd *cobra.Command, args []string, invokes ...any) error
- func (s *SetupContext) MakeInvokePreRunE(invokes ...any) func(cmd *cobra.Command, args []string) error
- func (s *SetupContext) PersistentPreRunE(cmd *cobra.Command, args []string) error
- type TestModuleInput
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", fx.Provide(newRigClient), fx.Provide(auth.NewService), fx.Provide(afero.NewOsFs), fx.Provide(scheme.New), fx.Provide(func(fs afero.Fs, prompter common.Prompter) (*cmdconfig.Config, error) { return cmdconfig.NewConfig("", fs, prompter) }), fx.Provide(zap.NewDevelopment), fx.Provide(getContext), fx.Provide(scope.NewScope), 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{} }), fx.Provide(func() scope.Interactive { return scope.Interactive(term.IsTerminal(int(os.Stdin.Fd()))) }), fx.Provide(func() common.Prompter { return common.StandardPrompter{} }), )
var StandardSetupContext = NewSetupContext(Module, nil)
Functions ¶
func GetClientOptions ¶ added in v1.8.14
func MakeTestModule ¶ added in v1.8.9
func MakeTestModule(i TestModuleInput) fx.Option
Types ¶
type ContextDependency ¶ added in v1.8.14
type ContextDependency interface{}
type FComplete ¶
func CtxWrapCompletion ¶
func CtxWrapCompletion(f FCompleteCtx) FComplete
func HackCtxWrapCompletion ¶ added in v1.8.9
func HackCtxWrapCompletion(f FCompleteCtxSetup, s *SetupContext) FComplete
func HackWrapCompletion ¶ added in v1.8.9
func HackWrapCompletion(f FCompleteSetup, s *SetupContext) FComplete
type FCompleteCtx ¶
type FCompleteCtxSetup ¶ added in v1.8.9
type FCompleteCtxSetup = func(context.Context, *cobra.Command, []string, string, *SetupContext) ([]string, cobra.ShellCompDirective)
type FCompleteSetup ¶ added in v1.8.9
type FCompleteSetup = func(*cobra.Command, []string, string, *SetupContext) ([]string, cobra.ShellCompDirective)
type PromptInformation ¶
type PromptInformation struct {
ContextCreation bool
}
type SetupContext ¶ added in v1.8.9
type SetupContext struct { BaseModule fx.Option Args []string AddTestCommand bool // contains filtered or unexported fields }
func NewSetupContext ¶ added in v1.8.10
func NewSetupContext(baseModule fx.Option, args []string) *SetupContext
func (*SetupContext) AddOptions ¶ added in v1.8.9
func (s *SetupContext) AddOptions(opts ...fx.Option)
func (*SetupContext) ExecuteInvokes ¶ added in v1.8.9
func (*SetupContext) InvokePreRunE ¶ added in v1.8.9
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 (*SetupContext) MakeInvokePreRunE ¶ added in v1.8.9
func (s *SetupContext) 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 (*SetupContext) PersistentPreRunE ¶ added in v1.8.9
func (s *SetupContext) 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 at 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.