command

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateRunFunc

func GenerateRunFunc(c Command) func(*cobra.Command, []string) error

GenerateRunFunc generic cobra handler If all required flags are set, the command's specific behavior is executed. Otherwise a survey is launched for allow the user to inject the data

Types

type Command

type Command interface {
	Execute() error
	Validate() error
	BuildSurvey() ([]*survey.Question, error)
	BuildCobraCommand() *cobra.Command
}

Command minimal command definition.

type ProjectPathCommand

type ProjectPathCommand struct {
	GoyaveMod     *modfile.Require
	GoyaveVersion *semver.Version
	ProjectPath   string
}

ProjectPathCommand shared composition struct for commands using a Goyave project path. All commands compositing with this one should call "setup()" first in their "Execute()" function. Commands using ProjectPathCommand should have a project path flag and survey entry.

func (*ProjectPathCommand) Setup

func (c *ProjectPathCommand) Setup() (int, error)

Setup ensure the `ProjectPath` field is correctly set. If `ProjectPath` is empty at the time `Setup()` is called, its value will be set to `fs.FindParentModule()`. The project's `go.mod` file is parsed and put into the `GoyaveMod` field. The Goyave framework version is parsed and put into the `GoyaveVersion` field.

type SetupCommand

type SetupCommand interface {
	// Setup returns the number of flags consumed by the setup operation.
	Setup() (int, error)
}

SetupCommand for commands needing to execute some logic before being executed. If a command implements "Setup()", this function will be called first, before surveys and validation.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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