cmd

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WrapSubCommand

func WrapSubCommand(cmd Command) *cobra.Command

func WrapSubCommands

func WrapSubCommands(commands []Command) []*cobra.Command

WrapSubCommands gives a list of sub commands

Types

type Command

type Command interface {
	// Cmd is the actual command name to execute.
	// For example: "app:serve"
	//
	Cmd() string

	// Short returns string about short description of the command
	// the string is shown in help screen of cobra command
	Short() string

	// Setup is used to setup flags or pre-run steps for the command.
	//
	// For example,
	//  cmd.Flags().IntVarP(&r.num, "num", "n", 5, "description")
	//
	Setup(cmd *cobra.Command)

	// Run runs the command runner
	// run returns command runner which is a function with dependency
	// injected arguments.
	//
	// For example,
	//  Command{
	//   Run: func(l core.Logger) {
	// 	   l.Info("i am working")
	// 	 },
	//  }
	//
	Run() CommandRunner

	// GetFXOpts is used to return the cmd specific FX configuration
	GetFXOpts() fx.Option
}

Command interface is used to implement sub-commands in the system.

type CommandRunner

type CommandRunner any

type ServeCommand

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

func NewServeCommand

func NewServeCommand(fxOpts fx.Option) *ServeCommand

func (*ServeCommand) Cmd

func (s *ServeCommand) Cmd() string

func (*ServeCommand) GetFXOpts

func (s *ServeCommand) GetFXOpts() fx.Option

func (*ServeCommand) Run

func (s *ServeCommand) Run() CommandRunner

func (*ServeCommand) Setup

func (s *ServeCommand) Setup(_ *cobra.Command)

func (*ServeCommand) Short

func (s *ServeCommand) Short() string

type ServeWorkCommand

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

func NewServeWorkCommand

func NewServeWorkCommand(fxCommonOpts, fxServerOpts, fxWorkerOpts fx.Option) *ServeWorkCommand

func (*ServeWorkCommand) Cmd

func (w *ServeWorkCommand) Cmd() string

func (*ServeWorkCommand) GetFXOpts

func (w *ServeWorkCommand) GetFXOpts() fx.Option

func (*ServeWorkCommand) Run

func (*ServeWorkCommand) Setup

func (w *ServeWorkCommand) Setup(_ *cobra.Command)

func (*ServeWorkCommand) Short

func (w *ServeWorkCommand) Short() string

type WorkCommand

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

func NewWorkCommand

func NewWorkCommand(fxOpts fx.Option) *WorkCommand

func (*WorkCommand) Cmd

func (w *WorkCommand) Cmd() string

func (*WorkCommand) GetFXOpts

func (w *WorkCommand) GetFXOpts() fx.Option

func (*WorkCommand) Run

func (w *WorkCommand) Run() CommandRunner

func (*WorkCommand) Setup

func (w *WorkCommand) Setup(_ *cobra.Command)

func (*WorkCommand) Short

func (w *WorkCommand) Short() string

Jump to

Keyboard shortcuts

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