shell

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BashShell

type BashShell struct {
	Path string //e.g., /bin/bash
	// contains filtered or unexported fields
}

BashShell represents a bash environment which maintains sanic's environment variables

func (*BashShell) ChangeEnvironment

func (shell *BashShell) ChangeEnvironment(sanicEnvironment string) error

ChangeEnvironment changes the currently entered shell's sanic environment to a new one

func (*BashShell) Enter

func (shell *BashShell) Enter() error

Enter : execvp the current process into a new sanic shell. Note: Does not return.

func (*BashShell) Exec

func (shell *BashShell) Exec(requestedCommand []string) (errorCode int, err error)

Exec : execute the given command without shell interpolation

func (*BashShell) GetSanicConfig

func (shell *BashShell) GetSanicConfig() string

GetSanicConfig returns the current path to the sanic configuration file

func (*BashShell) GetSanicEnvironment

func (shell *BashShell) GetSanicEnvironment() string

GetSanicEnvironment returns the current environment (e.g., "sanic env dev" -> dev)

func (*BashShell) GetSanicRoot

func (shell *BashShell) GetSanicRoot() string

GetSanicRoot returns the current path to the project root directory

func (*BashShell) ShellExec

func (shell *BashShell) ShellExec(requestedCommand string, args []string) (errorCode int, err error)

ShellExec : execute the given shell command (i.e., including spaces) in the given environment

type Shell

type Shell interface {
	//Enter this specific shell.
	//If not already in a sanic env, this will execp a new shell
	//If already in a sanic env, this will change the current shell's variables
	//In both cases, only returns with an error, otherwise execution is terminated
	Enter() error

	//Execute the given command in this shell
	Exec(requestedCommand []string) (errorCode int, err error)

	//Execute the given command in "Shell mode", i.e., allowing spaces
	ShellExec(requestedCommand string, args []string) (errorCode int, err error)

	//If "sanic env dev", return "dev"
	GetSanicEnvironment() string

	//return absolute path to the current shell's sanic project's root
	GetSanicRoot() string

	//return absolute path to the current shell's sanic project's config
	GetSanicConfig() string

	//must already be in an environment, this changes the current shell's environment to a new one
	ChangeEnvironment(sanicEnvironment string) error
}

Shell represents, broadly, the current shell environment we're in (by having executed sanic env) it keeps track of terminal state and allows executing commands.

func Current

func Current() (Shell, error)

Current gets the current shell (or an error if sanic env has not been used)

func New

func New(sanicRoot, sanicConfig, sanicEnvironment string) (Shell, error)

New creates a new sanic shell environment to execute commands in or to enter.

Jump to

Keyboard shortcuts

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