cmdutil

package
v0.0.0-...-0a43815 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package cmdutil holds functionality to run turbo via cobra. That includes flag parsing and configuration of components common to all subcommands

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CmdBase

type CmdBase struct {
	UI              cli.Ui
	UIFactory       ui.Factory
	Logger          hclog.Logger
	RepoRoot        turbopath.AbsoluteSystemPath
	Config          turbostate.Config
	APIClient       *client.APIClient
	SpacesAPIClient *client.APIClient
	TurboVersion    string
}

CmdBase encompasses configured components common to all turbo commands.

func (*CmdBase) LogError

func (b *CmdBase) LogError(format string, args ...interface{})

LogError prints an error to the UI

func (*CmdBase) LogInfo

func (b *CmdBase) LogInfo(msg string)

LogInfo logs an message and outputs it to the UI.

func (*CmdBase) LogWarning

func (b *CmdBase) LogWarning(prefix string, err error)

LogWarning logs an error and outputs it to the UI.

type Helper

type Helper struct {
	// TurboVersion is the version of turbo that is currently executing
	TurboVersion string
	// contains filtered or unexported fields
}

Helper is a struct used to hold configuration values passed via flag, env vars, config files, etc. It is not intended for direct use by turbo commands, it drives the creation of CmdBase, which is then used by the commands themselves.

func NewHelper

func NewHelper(turboVersion string, args *turbostate.ParsedArgsFromRust) *Helper

NewHelper returns a new helper instance to hold configuration values for the root turbo command.

func (*Helper) Cleanup

func (h *Helper) Cleanup(cliConfig *turbostate.ParsedArgsFromRust)

Cleanup runs the register cleanup handlers. It requires the flags to the root command so that it can construct a UI if necessary

func (*Helper) GetCmdBase

func (h *Helper) GetCmdBase(executionState *turbostate.ExecutionState) (*CmdBase, error)

GetCmdBase returns a CmdBase instance configured with values from this helper. It additionally returns a mechanism to set an error, so

func (*Helper) RegisterCleanup

func (h *Helper) RegisterCleanup(cleanup io.Closer)

RegisterCleanup saves a function to be run after turbo execution, even if the command that runs returns an error

Jump to

Keyboard shortcuts

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