cmdutil

package
v0.0.0-...-82ab749 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2024 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chdir

func Chdir() (err error)

Chdir changes the working directory to the value of the SUBSTRATE_ROOT environment variable, if set and non-empty. It returns the previous working directory and the error returned by os.Chdir.

func CheckForFish

func CheckForFish() bool

CheckForFish finds the name of Substrate's parent process (ppid) and if it's the fish shell, return true.

func DomainFlag

func DomainFlag(usage string) (
	*string,
	*pflag.Flag,
	func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective),
)

func EnvironmentFlag

func EnvironmentFlag(usage string) (
	*string,
	*pflag.Flag,
	func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective),
)

func Main

func Main(cmd *cobra.Command, args []string) (context.Context, *awscfg.Config, *cobra.Command, []string, io.Writer)

Main returns the arguments necessary for a typical subcommand's Main function so that it can be called as Main(cmdutil.Main(cmd.Context())).

func MainRedirect

func MainRedirect(cmd *cobra.Command, args []string, w io.Writer) (context.Context, *awscfg.Config, *cobra.Command, []string, io.Writer)

MainRedirect returns the arguments necessary for a typical subcommand's Main function with its output io.Writer redirected to w. Call the Main function as Main(cmdutil.MainRedirect(cmd.Context(), w)).

func NoCompletionFunc

func NoCompletionFunc(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective)

func OverrideArgs

func OverrideArgs(cmd *cobra.Command, args ...string)

OverrideArgs provides a way to test main functions that use package-level flag functions to parse command-line arguments. It must be called _before_ calling and package-level flag functions.

func ParentProcessName

func ParentProcessName() (string, error)

ParentProcessName returns the name of the parent process of the current process.

func PrintCredentials

func PrintCredentials(format Format, creds aws.Credentials)

func PrintCredentialsEnv

func PrintCredentialsEnv(creds aws.Credentials, isFish bool)

func PrintCredentialsExport

func PrintCredentialsExport(creds aws.Credentials, isFish bool)

func PrintCredentialsExportWithHistory

func PrintCredentialsExportWithHistory(creds aws.Credentials, isFish bool)

func PrintCredentialsJSON

func PrintCredentialsJSON(creds aws.Credentials)

func PrintRoot

func PrintRoot()

PrintRoot prints the current working directory, which is the Substrate repository if this function is called after Chdir. This isn't just a part of Chdir because it's low-stakes and too much information for read-only commands but important enough to spend a line of output on for commands that e.g. create accounts, which all arrange to call PrintRoot.

func ProcessName

func ProcessName(pid int) (string, error)

ProcessName returns the process name of the process with the given pid.

func QualityFlag

func QualityFlag(usage string) (
	*string,
	*pflag.Flag,
	func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective),
)

func QualityForEnvironment

func QualityForEnvironment(environment string) string

func QuietFlag

func QuietFlag() *pflag.Flag

func RestoreArgs

func RestoreArgs()

RestoreArgs puts everything back where it was. It should be called in a defer statement at the beginning of a test or benchmark function.

func SetTPM

func SetTPM(aws.Credentials) error

Linux users have to suck it up and set environment variables.

func SetenvFromTPM

func SetenvFromTPM(string) error

func UndoChdir

func UndoChdir() error

UndoChdir changes the working directory to whatever the working directory was before a prior call to Chdir. It panics if Chdir hasn't been called.

func WritableBinDirname

func WritableBinDirname() (string, error)

WritableBinDirname tries to preempt common tar(1) failures we encounter when the extraction directory isn't writable for some reason. It returns a writable directory name and a nil error or the empty string and a non-nil error.

Types

type Format

type Format string
const (
	FormatEnv               Format = "env"
	FormatExport            Format = "export"
	FormatExportWithHistory Format = "export-with-history"
	FormatJSON              Format = "json"
	FormatShell             Format = "shell"
	FormatText              Format = "text"
)

func FormatFlag

func FormatFlag(defaultFormat Format, validFormats []Format) (
	*Format,
	*pflag.Flag,
	func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective),
)

type FormatFlagError

type FormatFlagError Format

func (FormatFlagError) Error

func (err FormatFlagError) Error() string

Jump to

Keyboard shortcuts

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