cli

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package cli wires the cobra command tree for the readur binary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(args []string, stdout, stderr *os.File) error

Run is the single entry point invoked from main. It executes the cobra command tree, renders any error through the configured Writer (respecting --json), and returns the final error. Mapping error → exit code is the caller's responsibility (main.go).

Types

type ConfigProfileRow

type ConfigProfileRow struct {
	Name               string `json:"name"`
	ServerURL          string `json:"server_url"`
	Username           string `json:"username"`
	ObtainedAt         string `json:"obtained_at"`
	TokenExpiry        string `json:"token_expiry,omitempty"`
	InsecureSkipVerify bool   `json:"insecure_skip_verify"`
	HasToken           bool   `json:"has_token"`
	HasPassword        bool   `json:"has_password"`
}

ConfigProfileRow is a redacted view of a profile for display. Neither the token nor the optional saved password value is ever included — presence is exposed as a boolean.

type ConfigShowJSON

type ConfigShowJSON struct {
	ConfigPath string             `json:"config_path"`
	StateDir   string             `json:"state_dir"`
	Exists     bool               `json:"exists"`
	DefaultIs  string             `json:"default_profile,omitempty"`
	Profiles   []ConfigProfileRow `json:"profiles"`
	Example    string             `json:"example_config"`
	ExitCode   int                `json:"exit_code"`
}

ConfigShowJSON is the JSON shape emitted by `readur config show --json`.

type Globals

type Globals struct {
	ConfigPath         string
	ProfileFlag        string
	JSON               bool
	Quiet              bool
	Verbose            bool
	NoColor            bool
	InsecureSkipVerify bool

	Writer *output.Writer
}

Globals carries the resolved persistent-flag state after Cobra parses the root command. Commands read from this.

func BuildRoot

func BuildRoot() (*cobra.Command, *Globals)

BuildRoot constructs the top-level `readur` cobra.Command and registers every subcommand. The returned Globals pointer is shared with the subcommands via closure; callers should not mutate it.

type LabelRow

type LabelRow struct {
	ID            string `json:"id"`
	Name          string `json:"name"`
	Color         string `json:"color,omitempty"`
	Description   string `json:"description,omitempty"`
	DocumentCount int    `json:"document_count"`
	CreatedBy     string `json:"created_by,omitempty"`
	CreatedAt     string `json:"created_at,omitempty"`
}

LabelRow is the per-label record in JSON output. It mirrors the client.Label struct but trims zero-value timestamps to keep the output compact for the common case.

type LabelsListJSON

type LabelsListJSON struct {
	Labels   []LabelRow `json:"labels"`
	Total    int        `json:"total"`
	ExitCode int        `json:"exit_code"`
}

LabelsListJSON is the JSON shape emitted by `readur labels list --json`.

type LoginJSON

type LoginJSON struct {
	Profile        string `json:"profile"`
	ServerURL      string `json:"server_url"`
	Username       string `json:"username"`
	TokenExpiresAt string `json:"token_expires_at,omitempty"`
	PasswordSaved  bool   `json:"password_saved"`
	ExitCode       int    `json:"exit_code"`
}

LoginJSON is the JSON shape emitted by `readur login --json` on success. Matches contracts/json-output.md §login.

type UploadJSON

type UploadJSON struct {
	LocalPath  string   `json:"local_path"`
	DocumentID string   `json:"document_id"`
	SizeBytes  int64    `json:"size_bytes"`
	Labels     []string `json:"labels"`
	Title      string   `json:"title,omitempty"`
	OCREnabled *bool    `json:"ocr_enabled,omitempty"`
	Language   string   `json:"language,omitempty"`
	DurationMs int64    `json:"duration_ms"`
	ExitCode   int      `json:"exit_code"`
}

UploadJSON is the JSON shape emitted by `readur upload --json` on success (see contracts/json-output.md §upload).

type VersionInfo

type VersionInfo struct {
	Version   string `json:"version"`
	Commit    string `json:"commit"`
	BuildDate string `json:"build_date"`
	Go        string `json:"go"`
	ExitCode  int    `json:"exit_code"`
}

VersionInfo is the JSON shape emitted by `readur version --json`.

Jump to

Keyboard shortcuts

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