script

package
v0.0.0-...-8540621 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AgentStatusScript  = "px/agent_status"
	ServiceStatsScript = "px/service_stats"
)

This file has a list of well known scripts, that can be referenced from various part of the CLI.

Variables

View Source
var ErrMissingRequiredArgument = errors.New("missing required argument")

ErrMissingRequiredArgument specifies that a required script flag has not been provided.

View Source
var (
	// ErrScriptNotFound is returned when the requested script does not exist.
	ErrScriptNotFound = errors.New("Script not found (run `px run -l` to list available scripts)")
)

Functions

func ParseVisSpec

func ParseVisSpec(specJSON string) (*vispb.Vis, error)

ParseVisSpec parses the spec return nil on failure.

Types

type Arg

type Arg struct {
	Name  string
	Value string
}

Arg is a single script argument.

type BundleManager

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

BundleManager reads a script bundle.

func NewBundleManagerWithOrg

func NewBundleManagerWithOrg(bundleFiles []string, orgID, orgName string) (*BundleManager, error)

NewBundleManagerWithOrg reads the json bundle and initializes the bundle reader for a specific org.

func (*BundleManager) AddScript

func (b *BundleManager) AddScript(script *ExecutableScript) error

AddScript adds the specified script to the bundle manager.

func (BundleManager) GetOrderedScripts

func (b BundleManager) GetOrderedScripts() []*ExecutableScript

GetOrderedScripts returns metadata about available scripts ordered by the name of the script.

func (BundleManager) GetScript

func (b BundleManager) GetScript(scriptName string) (*ExecutableScript, error)

GetScript returns the script by name.

func (BundleManager) GetScripts

func (b BundleManager) GetScripts() []*ExecutableScript

GetScripts returns metadata about available scripts.

func (BundleManager) MustGetScript

func (b BundleManager) MustGetScript(scriptName string) *ExecutableScript

MustGetScript is GetScript with fatal on error.

type BundleWriter

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

BundleWriter creates script bundle files.

func NewBundleWriter

func NewBundleWriter(searchPaths []string, basePaths []string) *BundleWriter

NewBundleWriter created a new BundleWriter.

func (*BundleWriter) Write

func (b *BundleWriter) Write(outFile string) error

Writer writes the bundle file to the specified output.

type ExecutableScript

type ExecutableScript struct {
	ScriptString string
	ScriptName   string
	ShortDoc     string
	LongDoc      string
	Vis          *vispb.Vis
	OrgID        string
	Hidden       bool
	// Marks if this script is local rather than hosted.
	IsLocal bool
	// Args contains a map from name to argument info.
	Args map[string]Arg
}

ExecutableScript is the basic script entity that can be run.

func (*ExecutableScript) ComputedArgs

func (e *ExecutableScript) ComputedArgs() ([]Arg, error)

ComputedArgs returns the args as an array.

func (*ExecutableScript) GetFlagSet

func (e *ExecutableScript) GetFlagSet() *FlagSet

GetFlagSet returns the flagset for this script based on the variables.

func (e ExecutableScript) LiveViewLink(clusterID *string) string

LiveViewLink returns the fully qualified URL for the live view.

func (*ExecutableScript) UpdateFlags

func (e *ExecutableScript) UpdateFlags(fs *FlagSet) error

UpdateFlags updates the flags based on the passed in flag set.

type FlagSet

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

FlagSet is a wrapper around flag.FlagSet, because the latter does not support required args without a default value.

func NewFlagSet

func NewFlagSet(scriptName string) *FlagSet

NewFlagSet creates a new FlagSet.

func (*FlagSet) Lookup

func (f *FlagSet) Lookup(name string) (string, error)

Lookup wraps flag.FlagSet's Lookup function, returning an error if we look up a required arg (without a default value) that hasn't been set.

func (*FlagSet) Parse

func (f *FlagSet) Parse(arguments []string) error

Parse wraps flag.FlagSet's Parse function to parse args.

func (*FlagSet) Set

func (f *FlagSet) Set(name, value string) error

Set wraps flag.FlagSet's Set function.

func (*FlagSet) SetOutput

func (f *FlagSet) SetOutput(output io.Writer)

SetOutput wraps flag.FlagSet's SetOutput function.

func (*FlagSet) String

func (f *FlagSet) String(name string, defaultValue *string, usage string)

String is a wrapper around flag.FlagSet's String function. It declares the presence of an argument. It differs from FlagSet's string in that defaultValue is allowed to be nil.

func (*FlagSet) Usage

func (f *FlagSet) Usage()

Usage wraps flag.FlagSet's Usage function.

Jump to

Keyboard shortcuts

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