cmd

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 67 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 InspectConstructions added in v0.17.0

type InspectConstructions struct {
	Mode   string `json:"mode"`
	Digest string `json:"digest,omitempty"`
}

InspectConstructions is the constructions mode SHAPE found and, in full mode, the digest it computed of the text (SPEC.md section 7.2).

type InspectDeclaredTime added in v0.17.0

type InspectDeclaredTime struct {
	Part  string `json:"part"`
	Class string `json:"class"`
	Value any    `json:"value"`
}

InspectDeclaredTime is one time the proof carries, at its pointer, of its class, as carried: declared by the signer, never a fact and never an edge of a submission window (SPEC.md sections 11 and 11.5).

type InspectOutput added in v0.17.0

type InspectOutput struct {
	Source        string                `json:"source"`
	Octets        *int                  `json:"octets"`
	Rejection     *InspectRejection     `json:"rejection"`
	Signature     *InspectSignature     `json:"signature"`
	KeyID         *string               `json:"key_id"`
	ProofHash     *string               `json:"proof_hash"`
	Proof         *InspectProof         `json:"proof"`
	Recomputed    []InspectRecomputed   `json:"recomputed"`
	DeclaredTimes []InspectDeclaredTime `json:"declared_times"`
	Recorded      []InspectRecorded     `json:"recorded"`
	ItemCode      *string               `json:"item_code"`
}

InspectOutput is what `truestamp inspect` writes: the --json shape, and the one source of the text. Octets is the size read, and null for an input over MAX_READ_OCTETS, which is read only one octet past that bound. Rejection is set exactly when the reader or SHAPE refused the document; Signature, KeyID and ProofHash once ENVELOPE passed; Proof once SHAPE passed, and Recomputed, DeclaredTimes and Recorded, empty before, with it. Each member of the proof is given once, by its value class (SPEC.md section 3.7): a CHECKED value in Recomputed, a time in DeclaredTimes, a RECORDED value in Recorded, and every other in Proof. ItemCode is no member of the proof: it is the item code of SPEC.md section 3.9 (The item code), computed from the item_hash recomputed from an item proof's record, its Recomputed row at /subject/item_hash, and null for any other proof, before SHAPE passes, and when that item_hash cannot be recomputed. A match of codes shows only that two item_hash values begin with the same 75 bits.

type InspectProof added in v0.13.0

type InspectProof struct {
	Block           any                  `json:"block"`
	Commitments     any                  `json:"commitments"`
	Constructions   InspectConstructions `json:"constructions"`
	Environment     any                  `json:"environment"`
	Format          any                  `json:"format"`
	Observations    any                  `json:"observations,omitzero"`
	SigningKeyEvent any                  `json:"signing_key_event"`
	Subject         any                  `json:"subject,omitzero"`
	Type            any                  `json:"type"`
	Version         any                  `json:"version"`
	Witnesses       any                  `json:"witnesses,omitzero"`
}

InspectProof is what the proof member carries but its CHECKED values, its times and its RECORDED values, each member as the proof holds it (verifier.Inspection's Carried), with two in another form: the claims as claims_members in the subject, their names, which are the submitter's statement and never checked as true, and the constructions member as the mode SHAPE found and, in full mode, the digest it computed of the text (SPEC.md section 7.2). Environment is the marker, null for a production proof, and SigningKeyEvent is null when the proof carries none.

type InspectRecomputed added in v0.17.0

type InspectRecomputed struct {
	Construction string `json:"construction"`
	Part         string `json:"part"`
	Carried      any    `json:"carried"`
	CarriedIs    string `json:"carried_is,omitempty"`
	Value        any    `json:"value"`
	ValueIs      string `json:"value_is,omitempty"`
}

InspectRecomputed is one CHECKED value of the proof: the row of the constructions text that defines it, its pointer, the value the proof carries there, and the value recomputed from what the proof carries, null when there is none (verifier.Recomputed). A handover_signature's row alone has CarriedIs "signature" and ValueIs "signed_message": its carried value is the signature, and its value the 32 octets of the message that signature signs, which is not compared with it.

type InspectRecorded added in v0.17.0

type InspectRecorded struct {
	Part  string `json:"part"`
	Value any    `json:"value"`
}

InspectRecorded is one RECORDED value of the proof, at its pointer: declared by the signer, and not attributed to Truestamp (SPEC.md sections 3.7 and 11.5).

type InspectRejection added in v0.17.0

type InspectRejection struct {
	Code      string  `json:"code"`
	Message   string  `json:"message"`
	Part      *string `json:"part"`
	Step      string  `json:"step"`
	SubReason string  `json:"sub_reason,omitempty"`
}

InspectRejection is the verifier's refusal: a bare rejection of READ, PARSE or ENVELOPE (SPEC.md section 10.2, the gate), with its sub_reason where it has one and part null, or SHAPE's failing row, with its part.

type InspectSignature added in v0.17.0

type InspectSignature struct {
	Alg       string `json:"alg"`
	PublicKey string `json:"public_key"`
	Value     string `json:"value"`
}

InspectSignature is the envelope's signature member, as carried.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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