Help us shape the future of Go! Take the 2026 Go Developer Survey

cli

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package cli provides functions to parse command-line arguments and flags.

Index

Constants

View Source
const (
	InitCommand  = "init"
	RunCommand   = "run"
	ServeCommand = "serve"
	BuildCommand = "build"
)

Variables

View Source
var (
	ErrUnknownFlag  = errors.New("unknown flag")
	ErrRequiredFlag = errors.New("required flag")
	ErrNoCommand    = errors.New("no command")
)
View Source
var ErrUnknownCommand = errors.New("unknown command")

Functions

func ApplyBuildFlags

func ApplyBuildFlags(cfg *config.Configuration, flags BuildFlags)

ApplyBuildFlags applies build flags to configuration.

func ApplyInitFlags

func ApplyInitFlags(cfg *config.Configuration, flags InitFlags)

ApplyInitFlags applies init flags to configuration.

func ApplyRunFlags

func ApplyRunFlags(cfg *config.Configuration, flags RunFlags)

ApplyRunFlags applies run flags to configuration.

func ApplyServeFlags

func ApplyServeFlags(cfg *config.Configuration, flags ServeFlags)

ApplyServeFlags applies serve flags to configuration.

Types

type BuildFlags

type BuildFlags struct {
	Template string
}

BuildFlags contains flags for the build command.

type Command

type Command struct {
	Name       string
	InitFlags  InitFlags
	RunFlags   RunFlags
	ServeFlags ServeFlags
	BuildFlags BuildFlags
	Help       bool
	Version    bool
	IsClient   bool
}

Command contains command, flags and options for the application. Should be used together with config.Configuration to create configuration and determine run mode for the application.

func Parse

func Parse(args []string) (Command, error)

Parse arguments from os.Args and return a CLI.

func (Command) PrintHelp

func (c Command) PrintHelp()

PrintHelp prints the available commands.

type InitFlags

type InitFlags struct{}

InitFlags contains flags for the init command.

type RunFlags

type RunFlags struct {
	Address      string
	Command      string
	StderrBuffer bool
	Args         []string
}

RunFlags contains flags for the run command.

type ServeFlags

type ServeFlags struct {
	Address    string
	Container  bool
	Env        map[string]string
	Volumes    map[string]string
	Workspaces []string
	CPUs       float64
	Memory     string
}

ServeFlags contains flags for the serve command.

Jump to

Keyboard shortcuts

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