cmd

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: MIT Imports: 51 Imported by: 0

Documentation

Overview

Package cmd wires up the cobra command tree for the Truestamp CLI. The main entrypoint (cmd/truestamp/main.go) calls Execute; everything else here registers subcommands, flags, and the shared PersistentPreRunE that loads the resolved configuration into [appConfig].

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute() (err error)

Execute runs the root command. Commands set SilenceErrors so cobra does not print their errors; Execute is the single place errors reach stderr. A command that needs silent-on-error UX (e.g. `verify --silent`) returns errSilentFail instead of the real error to opt out of printing. The upgrade --check flow uses exitCodeErr to return a specific exit code without also printing an error line.

An unrecovered panic anywhere under rootCmd.Execute() is caught by the deferred recover below: the panic value and stack are written to the log file as a `command_end` record at error level (so a "the CLI crashed" support report has a forensic trail), the same stack is re-emitted on stderr in the runtime's default `panic: <value>\n\n <stack>` format so the operator sees what they would have seen without our wrapper, and the process exits with code 2 (matching the Go runtime's default panic exit code).

func ExitCode added in v0.3.1

func ExitCode(err error) int

ExitCode returns the code to pass to os.Exit for a given error. Falls back to 1 for generic errors, 0 for nil, or the stored code when err wraps an exitCodeErr.

func LoggerFrom added in v0.8.0

func LoggerFrom(ctx context.Context) *slog.Logger

LoggerFrom returns the logger attached to ctx, or a discard logger if no logger was injected (e.g. tests that bypass PersistentPreRunE, or the completion / help fast paths).

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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