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

argv

package
v0.0.174 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package argv builds Codex CLI command lines from structured options.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Argv

func Argv(opts Options) ([]string, error)

Argv builds the full Codex command line.

func EnsureBoolFlag

func EnsureBoolFlag(args []string, flag string) []string

EnsureBoolFlag ensures argv contains a bare boolean flag token exactly once.

func EnsureConfigFlag

func EnsureConfigFlag(args []string, key, value string) []string

EnsureConfigFlag ensures argv has paired "-c" "key=value" (preferred form).

func EnsureDisableFeature

func EnsureDisableFeature(args []string, name string) []string

EnsureDisableFeature ensures "--disable" "<name>" appears once.

func EnsureTrustedProject added in v0.0.160

func EnsureTrustedProject(args []string, absPath string) []string

EnsureTrustedProject appends -c projects."<absPath>".trust_level=trusted when absPath is non-empty. Idempotent for the same key.

func HasConfigKey

func HasConfigKey(args []string, key string) bool

HasConfigKey reports whether args already contain -c/--config for key (either "key=…" or bare "key" as the config value token).

func ParseShellWords

func ParseShellWords(line string) ([]string, error)

ParseShellWords splits a shell-style command line into argv words.

func TrustProject added in v0.0.160

func TrustProject(absPath string) map[string]codexcfg.Project

TrustProject returns a Projects map that marks absPath as trusted.

Types

type Options

type Options struct {
	// Bin is argv[0] when CommandOverride is empty.
	Bin string
	// UserFlags are inserted after Bin (settings / runner-spec extras).
	UserFlags []string

	Model           string
	ResumeSession   string
	ReasoningEffort string

	BypassApprovalsAndSandbox bool
	BypassHookTrust           bool
	DisableUpdateCheck        bool
	EmptyMCPServers           bool

	// DisableFeatures appends --disable <name> for each entry (deduped).
	DisableFeatures []string

	// Projects is a typed overlay of config.toml [projects."<path>"].
	// Emitted as -c projects."<path>".trust_level=<level>. Wins over ExtraConfig
	// for the same dotted keys.
	Projects map[string]codexcfg.Project

	// ExtraConfig is an escape hatch for arbitrary -c key=value (dotted paths).
	ExtraConfig map[string]string
	ExtraBool   []string

	// CommandOverride, when set, replaces Bin+UserFlags with shell-split words.
	// Session fields (Model/Resume) are not applied on override; knobs still apply
	// when set on Options (callers choose which knobs for hooks).
	CommandOverride string
}

Options configures a Codex process argv. Callers resolve the binary (and optional user flags) then set Bin / UserFlags, or set CommandOverride for test/fake TUI hooks.

func Interactive

func Interactive() Options

Interactive returns agent-run TTY defaults (approvals bypass, no update check, hook-trust bypass). Does not empty MCP or disable features.

func StatusInspect

func StatusInspect() Options

StatusInspect returns the stronger ephemeral /status fetch defaults: approvals + hook-trust bypass, no update check, empty mcp_servers, and disable plugins / computer_use / in_app_updates / hooks.

Jump to

Keyboard shortcuts

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