Documentation
¶
Index ¶
Constants ¶
const ( ExitOK = 0 ExitError = 1 // generic error not covered below ExitUsage = 2 // unknown command/flag or bad arg count ExitNotRepo = 3 // cwd is not a drift repository ExitNetwork = 4 // network error (upgrade, push, pull, clone, ls-remote) ExitConflict = 5 // workspace locked, branch/tag already exists, etc. )
Exit codes returned by Execute. They are intentionally stable so that scripts and shell pipelines can branch on them. The names mirror the failure category, not the specific sentinel, so additional sentinels can be added without breaking the contract.
Variables ¶
var ErrSilent = errors.New("silent error (already reported)")
ErrSilent indicates that an error was already displayed to the user via statusFailed, and Execute() should exit with code 1 without printing the error again.
Functions ¶
func Execute ¶
func Execute() int
Execute runs the root command and returns a process exit code. The caller (main) should pass the return value to os.Exit. Errors are classified by sentinel identity so scripts can branch on ExitNotRepo, ExitNetwork, ExitConflict, etc. ErrSilent means the error was already displayed via reportFailed; it maps to ExitError.
Types ¶
type JSONEnvelope ¶
type JSONEnvelope struct {
Command string `json:"command"`
Status string `json:"status"` // ok / failed / warning / active
Error string `json:"error,omitempty"` // error message when status == "failed"
ErrorDetail string `json:"error_detail,omitempty"` // verbose: underlying error cause
Data interface{} `json:"data,omitempty"`
Hint *string `json:"hint"`
}
JSONEnvelope is the unified output envelope for --json mode. All commands supporting --json emit this structure so that scripts can parse a single schema regardless of the command. Hint is a pointer so that an absent hint serializes as JSON null (per docs/cli-design.md), matching the design's "hint": null example, rather than being omitted. ErrorDetail is populated only when --verbose is set and an underlying error is available, so scripts can access the real error cause.
Source Files
¶
- branch.go
- check.go
- clone.go
- config.go
- console_unix.go
- diff.go
- diff_file_json.go
- diff_json.go
- diff_stat.go
- export.go
- gc.go
- ignore.go
- import.go
- init.go
- json_output.go
- log.go
- log_format.go
- log_json.go
- ls_remote.go
- output.go
- pull.go
- push.go
- remote.go
- remote_add.go
- resolve.go
- restore.go
- root.go
- save.go
- show.go
- show_json.go
- show_open.go
- status.go
- switch.go
- tag.go
- undo.go
- upgrade.go
- version.go
- watch.go