cmdutil

package
v1.48.7-circular Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2025 License: MPL-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoEncoreApp    = errors.New("no encore.app found in directory (or any of the parent directories)")
	ErrEncoreAppIsDir = errors.New("encore.app is a directory, not a file")
)
View Source
var Newline string

Functions

func AppRoot

func AppRoot() (appRoot, relPath string)

AppRoot is like MaybeAppRoot but instead of returning an error it prints it to stderr and exits.

func AppSlug

func AppSlug() string

AppSlug reports the current app's app slug. It throws a fatal error if the app is not connected with the Encore Platform.

func AppSlugOrLocalID

func AppSlugOrLocalID() string

func AutoCompleteAppSlug

func AutoCompleteAppSlug(cmd *cobra.Command, _ []string, toComplete string) ([]string, cobra.ShellCompDirective)

func AutoCompleteEnvSlug

func AutoCompleteEnvSlug(cmd *cobra.Command, args []string, toComplete string) (rtn []string, dir cobra.ShellCompDirective)

func AutoCompleteFromStaticList

func AutoCompleteFromStaticList(args ...string) func(cmd *cobra.Command, _ []string, toComplete string) ([]string, cobra.ShellCompDirective)

func ClearTerminalExceptFirstNLines

func ClearTerminalExceptFirstNLines(n int)

func ConnectDaemon

func ConnectDaemon(ctx context.Context) daemonpb.DaemonClient

ConnectDaemon returns a client connection to the Encore daemon. By default, it will start the daemon if it is not already running.

func DisplayError

func DisplayError(out *os.File, err []byte)

func Fatal

func Fatal(args ...any)

func Fatalf

func Fatalf(format string, args ...any)

func FindAppRootFromDir

func FindAppRootFromDir(dir string) (appRoot, relPath string, err error)

func FormatStack

func FormatStack(val any, buf *bytes.Buffer) error

func IsDaemonRunning

func IsDaemonRunning(ctx context.Context) bool

func MaybeAppRoot

func MaybeAppRoot() (appRoot, relPath string, err error)

MaybeAppRoot determines the app root by looking for the "encore.app" file, initially in the current directory and then recursively in parent directories up to the filesystem root.

It reports the absolute path to the app root, and the relative path from the app root to the working directory.

func StartDaemonInBackground

func StartDaemonInBackground(ctx context.Context) error

StartDaemonInBackground starts the Encore daemon in the background.

func StopDaemon

func StopDaemon()

func StreamCommandOutput

func StreamCommandOutput(stream CommandOutputStream, converter OutputConverter) int

StreamCommandOutput streams the output from the given command stream, and reports the command's exit code. If convertJSON is true, lines that look like JSON are fed through zerolog's console writer.

func WorkspaceRoot

func WorkspaceRoot(appRoot string) string

WorkspaceRoot determines the workspace root by looking for the .git folder in app root or parents to it. It reports the absolute path to the workspace root.

Types

type CommandOutputStream

type CommandOutputStream interface {
	Recv() (*daemon.CommandMessage, error)
}

CommandOutputStream is the interface for gRPC streams that stream the output of a command.

type ConvertLogOption

type ConvertLogOption func(*ConvertLogOptions)

func Colorize

func Colorize(enable bool) ConvertLogOption

type ConvertLogOptions

type ConvertLogOptions struct {
	Color bool
}

type Oneof

type Oneof struct {
	Value       string
	Allowed     []string
	Flag        string // defaults to "output" if empty
	FlagShort   string // defaults to "o" if both Flag and FlagShort are empty
	Desc        string // usage desc
	TypeDesc    string // type description, defaults to the name of the flag
	NoOptDefVal string // default value when no option is provided
}

func (*Oneof) AddFlag

func (o *Oneof) AddFlag(cmd *cobra.Command)

func (*Oneof) Alternatives

func (o *Oneof) Alternatives() string

Alternatives lists the alternatives in the format "a|b|c".

func (*Oneof) FlagName

func (o *Oneof) FlagName() (name, short string)

func (*Oneof) Set

func (o *Oneof) Set(v string) error

func (*Oneof) String

func (o *Oneof) String() string

func (*Oneof) Type

func (o *Oneof) Type() string

func (*Oneof) Usage

func (o *Oneof) Usage() string

type OutputConverter

type OutputConverter func(line []byte) []byte

func ConvertJSONLogs

func ConvertJSONLogs(opts ...ConvertLogOption) OutputConverter

Jump to

Keyboard shortcuts

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