cli

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package cli is keyforge's command line: Cobra commands over the HTTP control plane.

The commands are a client of the control plane and hold no logic of their own, so there is one implementation of each operation and the command line cannot do what the service would refuse. Two transports are offered:

  • A remote server, named by --server or KEYFORGE_SERVER, with a bearer token from --token-file or KEYFORGE_TOKEN. This is the standalone `keyforge` binary.
  • An in-process handler, for a host that embeds the commands in its own binary and has the control plane in the same process. No network is involved, and the host's own authorizer and actor naming apply.

A few commands need no server: generating a root key, and reading the header of a keyring file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRootCommand

func NewRootCommand(opts Options) *cobra.Command

NewRootCommand returns the `keyforge` command with every subcommand attached.

Types

type APIError

type APIError struct {
	Status  int
	Code    string
	Message string
}

APIError is an error response from the control plane.

func (*APIError) Error

func (e *APIError) Error() string

Error implements error.

type Options

type Options struct {
	// Handler, when set, is the control plane in this process; --server is then
	// not needed and no network is used.
	Handler http.Handler
	// Out and Err default to the standard streams.
	Out, Err io.Writer
	// HTTPClient is used for a remote server. The default has a timeout.
	HTTPClient *http.Client
	// Env reads an environment variable; the default is os.Getenv.
	Env func(string) string
}

Options configures the command tree.

Jump to

Keyboard shortcuts

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