cli

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package cli implements the CLI functionality, main defers execution to the exported methods in this package

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	Stdout io.Writer      // Normal CLI output
	Stderr io.Writer      // Where the logger and errors will write to
	Logger *logrus.Logger // The debug logger
	Path   string         // The path to search through i.e. $PATH, passable field to facilitate testing
}

App represents the py program.

func New

func New(stdout, stderr io.Writer) *App

New creates a new default App configured to write to 'stdout' and DEBUG log to 'stderr'.

func (*App) Help

func (a *App) Help()

Help shows py's help text and usage info.

func (*App) Launch

func (a *App) Launch(args []string) error

Launch will follow py's control flow and launch whatever is the most appropriate python any arguments specified in 'args' will be passed through to the found python Control flow for no args is:

  1. Activated virtual environment
  2. .venv directory
  3. venv directory
  4. Look for a python shebang line in the file (if we have a file)
  5. PY_PYTHON env variable
  6. Latest version on $PATH

func (*App) LaunchExact

func (a *App) LaunchExact(major, minor int, args []string) error

LaunchExact will search through $PATH, find the latest python interpreter satisfying the constraint imposed by both 'major' and 'minor' version passed launch it, and pass through any args passed to it.

func (*App) LaunchLatest

func (a *App) LaunchLatest(args []string) error

LaunchLatest will search through $PATH, find the latest python interpreter and launch it, passing through any arguments passed to it.

func (*App) LaunchMajor

func (a *App) LaunchMajor(major int, args []string) error

LaunchMajor will search through $PATH, find the latest python interpreter satisfying the constraint imposed by 'major' version passed launch it, and pass through any arguments passed to it.

func (*App) List

func (a *App) List() error

List shows a list of all python interpreters on $PATH, sorted latest to oldest.

Jump to

Keyboard shortcuts

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