cli

package
v0.0.0-...-903b831 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 40 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cli implements the `falak` command-line client for the control-plane public API.

Index

Constants

View Source
const (
	ExitOK           = 0
	ExitError        = 1
	ExitUsage        = 2
	ExitDeployFailed = 3
)

Exit codes.

View Source
const (
	ExitInvalid  = 5 // the file is invalid
	ExitApproval = 6 // the run waits for an approval
)

Exit codes of the config commands (docs/plans/CONFIG_AS_CODE.md, "CLI").

View Source
const ExitConflict = 4

ExitConflict: `falak fn deploy` found a newer version than its base (pull, or deploy with --force).

View Source
const ExitDrift = 7

ExitDrift: `falak drift` found the environment drifted from its last applied file.

View Source
const ExitTimeout = 124

ExitTimeout: `falak sandbox exec` hit its --timeout (as timeout(1)).

Variables

This section is empty.

Functions

func ConfigDir

func ConfigDir(getenv func(string) string) (string, error)

ConfigDir resolves the CLI config dir: $FALAK_CONFIG_DIR, else os.UserConfigDir()/falak (~/Library/Application Support/falak on macOS, $XDG_CONFIG_HOME/falak or ~/.config/falak on Linux).

func DeleteCredentials

func DeleteCredentials(dir string) error

DeleteCredentials removes stored credentials (no error when absent).

func SaveCredentials

func SaveCredentials(dir string, c Credentials) error

SaveCredentials writes atomically with 0600 (dir 0700).

Types

type App

type App struct {
	Stdout io.Writer
	Stderr io.Writer
	Stdin  io.Reader
	Getenv func(string) string
	// NewAPI builds the API client (tests may return a fake).
	NewAPI func(baseURL, token string) api.API
	// Exec replaces the process (ssh). Open opens a URL in a browser.
	Exec func(argv []string) error
	Open func(url string) error
	// Poll is the interval for --wait / --follow polling.
	Poll    time.Duration
	Version string
	// Interactive reports whether Stdin is a terminal (login prompt).
	Interactive bool
	// ReadSecret reads a line without echo (interactive login); nil falls back to Stdin.
	ReadSecret func() (string, error)
	// Executable is the binary `falak update` replaces; nil means os.Executable.
	Executable func() (string, error)
	// Dir is the working directory ("" = the process's).
	Dir string
	// GitBranch returns the current branch of the repository holding dir (nil: runs git).
	GitBranch func(dir string) string
	// Terminal is the local terminal for `falak console` (nil: stdin isn't a terminal).
	Terminal Terminal
	// contains filtered or unexported fields
}

App holds I/O and injectable dependencies; one App serves one invocation.

func (*App) Run

func (a *App) Run(ctx context.Context, argv []string) int

Run executes argv (without the program name) and returns the process exit code.

type Credentials

type Credentials struct {
	URL          string `json:"url"`
	Token        string `json:"token"`
	User         string `json:"user,omitempty"`
	Organization string `json:"organization,omitempty"`
}

Credentials are stored in <config dir>/falak/credentials.json with mode 0600.

func LoadCredentials

func LoadCredentials(dir string) (Credentials, error)

LoadCredentials returns zero Credentials when none are stored.

type Terminal

type Terminal interface {
	// MakeRaw puts the terminal into raw mode (Ctrl-C and friends go to the remote shell) and returns its undo.
	MakeRaw() (restore func(), err error)
	Size() (cols, rows int, err error)
	// Resized signals every window size change until stop is called.
	Resized() (changes <-chan struct{}, stop func())
}

Terminal is the local terminal `falak console` drives. App.Terminal is nil when stdin isn't a terminal: no raw mode and no resizes (piped keystrokes still work).

func StdTerminal

func StdTerminal() Terminal

StdTerminal is the process's terminal for `falak console`, or nil when stdin isn't one.

Directories

Path Synopsis
Package api is the typed client for the Falak control-plane public REST API.
Package api is the typed client for the Falak control-plane public REST API.

Jump to

Keyboard shortcuts

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