command

package
v0.0.337-pre-1 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2022 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package command implements helpers useful for when building cobra commands.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotImplementedYet = errors.New("command not implemented yet")

TODO: remove once all commands are implemented.

Functions

func ChangeWorkingDirectoryToFirstArgIfPresent

func ChangeWorkingDirectoryToFirstArgIfPresent(ctx context.Context) (context.Context, error)

func FromContext

func FromContext(ctx context.Context) *cobra.Command

FromContext returns the Command ctx carries. It panics in case ctx carries no Command.

func LoadAppConfigIfPresent

func LoadAppConfigIfPresent(ctx context.Context) (context.Context, error)

LoadAppConfigIfPresent is a Preparer which loads the application's configuration file from the path the user has selected via command line args or the current working directory.

func LoadAppNameIfPresent

func LoadAppNameIfPresent(ctx context.Context) (context.Context, error)

LoadAppNameIfPresent is a Preparer which adds app name if the user has used --app or there appConfig but unlike RequireAppName it does not error if the user has not specified an app name.

func New

func New(usage, short, long string, fn Runner, p ...Preparer) *cobra.Command

func NewContext

func NewContext(ctx context.Context, cmd *cobra.Command) context.Context

NewContext derives a context that carries cmd from ctx.

func RequireAppName

func RequireAppName(ctx context.Context) (context.Context, error)

RequireAppName is a Preparer which makes sure the user has selected an application name via command line arguments, the environment or an application config file (fly.toml). It embeds LoadAppConfigIfPresent.

func RequireSession

func RequireSession(ctx context.Context) (context.Context, error)

RequireSession is a Preparer which makes sure a session exists.

func WrapRunE

func WrapRunE(fn func(*cobra.Command, []string) error) func(*cobra.Command, []string) error

TODO: remove after migration is complete

Types

type Preparer

type Preparer func(context.Context) (context.Context, error)

type Runner

type Runner func(context.Context) error

Directories

Path Synopsis
Package agent implements the agent command chain.
Package agent implements the agent command chain.
Package apps implements the apps command chain.
Package apps implements the apps command chain.
Package auth implements the auth command chain.
Package auth implements the auth command chain.
Package apps implements the apps command chain.
Package apps implements the apps command chain.
Package curl implements the curl command chain.
Package curl implements the curl command chain.
Package dig implements the dig command chain.
Package dig implements the dig command chain.
Package docs implements the docs command chain.
Package docs implements the docs command chain.
Package doctor implements the doctor command chain.
Package doctor implements the doctor command chain.
Package history implements the history command chain.
Package history implements the history command chain.
Package logs implements the logs command chain.
Package logs implements the logs command chain.
Package platform implements the platform command chain.
Package platform implements the platform command chain.
Package root implements the root command.
Package root implements the root command.
Package services implements the services command chain.
Package services implements the services command chain.
postgres
Package postgres implements the postgres command chain.
Package postgres implements the postgres command chain.
redis
Package redis implements the redis command chain.
Package redis implements the redis command chain.
Package status implements the status command chain.
Package status implements the status command chain.
Package version implements the version command chain.
Package version implements the version command chain.

Jump to

Keyboard shortcuts

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