cmd

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: Apache-2.0 Imports: 60 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. rootCmd sets SilenceErrors, which cobra honours for every command under it, so 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

type InspectBlock added in v0.13.0

type InspectBlock struct {
	ID                string   `json:"id"`
	PreviousBlockHash string   `json:"previous_block_hash"`
	MerkleRoot        string   `json:"merkle_root"`
	SigningKeyID      string   `json:"signing_key_id"`
	MetadataKeys      []string `json:"metadata_keys"`
}

InspectBlock describes a block map.

type InspectCommit added in v0.13.0

type InspectCommit struct {
	Chain           string        `json:"chain"`
	Network         string        `json:"network,omitempty"`
	EpochMerkleRoot string        `json:"epoch_merkle_root"`
	EpochProof      *InspectProof `json:"epoch_proof"`
	TransactionHash string        `json:"transaction_hash,omitempty"`
	Timestamp       string        `json:"timestamp,omitempty"`
	Ledger          *int          `json:"ledger,omitempty"`
	BlockHeight     *int          `json:"block_height,omitempty"`
	OfflineEvidence []string      `json:"offline_evidence,omitempty"`
}

InspectCommit describes a commitment entry.

type InspectKeyEvent added in v0.13.0

type InspectKeyEvent struct {
	Block       InspectBlock    `json:"block"`
	Type        string          `json:"type,omitempty"`
	KeyID       string          `json:"key_id,omitempty"`
	Sequence    json.RawMessage `json:"sequence,omitempty"`
	Commitments []InspectCommit `json:"commitments"`
}

InspectKeyEvent describes the signing key event.

type InspectProof added in v0.13.0

type InspectProof struct {
	Depth int    `json:"depth"`
	Error string `json:"error,omitempty"`
}

InspectProof describes a compact Merkle proof without walking it.

type InspectSubject added in v0.13.0

type InspectSubject struct {
	ID                 string            `json:"id"`
	SigningKeyID       string            `json:"signing_key_id"`
	ClaimsKeys         []string          `json:"claims_keys,omitempty"`
	EntropyKeys        []string          `json:"entropy_keys,omitempty"`
	CommittedWitnesses map[string]string `json:"committed_witnesses"`
	CarriedWitnesses   []string          `json:"carried_witnesses"`
}

InspectSubject describes the subject map.

type InspectSummary added in v0.13.0

type InspectSummary struct {
	Source          string           `json:"source"`
	Format          string           `json:"format"`
	Bytes           int              `json:"bytes"`
	Version         json.RawMessage  `json:"version"`
	Type            string           `json:"type"`
	GeneratedAt     string           `json:"generated_at"`
	PublicKey       string           `json:"public_key"`
	KeyID           string           `json:"key_id,omitempty"`
	Subject         *InspectSubject  `json:"subject,omitempty"`
	InclusionProof  *InspectProof    `json:"inclusion_proof,omitempty"`
	Block           InspectBlock     `json:"block"`
	BlockPath       []InspectBlock   `json:"block_path,omitempty"`
	Commitments     []InspectCommit  `json:"commitments"`
	SigningKeyEvent *InspectKeyEvent `json:"signing_key_event,omitempty"`
}

InspectSummary is the machine-readable shape of `truestamp inspect`.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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