ideacli

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 23 Imported by: 0 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 ideacli is the idea commands and what the pursuit commands share: talking to the engine, the one interactive test, choosing a slug, opening an editor, and styles.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Appetite

func Appetite(n int64) string

Appetite writes a pursuit's appetite, or "none" when it has none.

func BadRequest

func BadRequest(err error) bool

BadRequest reports whether err is the engine refusing what was asked, as opposed to a fault.

func Command

func Command(newForge func(dir string) forge.Forge) *cobra.Command

Command returns the idea group, naming people through the forge newForge builds for a repo.

func Facts

func Facts(o client.IdeaOut) string

Facts says where an idea stands: its latest pursuit's state, or that it was never pursued.

func Failed

func Failed(stderr io.Writer, name string, err error) int

Failed says what went wrong and returns the exit code: for a UsageError its message, then command.BadUsage so the command's help follows; else "physa <name>: <err>" and 2. An engine's refusal is shown as its message alone.

func JSON

func JSON(fs *pflag.FlagSet, on *bool)

JSON declares the --json switch on fs, bound to on and off by default.

func String

func String(fs *pflag.FlagSet, name string, v *string)

String declares --name on fs as a flag with a value, bound to v and empty by default; the glue rejects an empty value typed on the line.

func When

func When(s string) string

When shows an RFC 3339 time from the engine as a person reads it, in UTC to the minute; a time that does not parse is shown as it is.

func WriteTemp

func WriteTemp(pattern, md string) (string, error)

WriteTemp writes md to a new temporary file named by pattern (as os.CreateTemp takes it) and returns its path.

func Written

func Written(stderr io.Writer, name string, err error) int

Written returns 0 for a nil err, else what Failed returns.

Types

type Choice

type Choice struct{ Slug, Text, Detail string }

Choice is one slug a person may choose, with the text it stands for and the facts shown beside it in the picker.

func IdeaChoices

func IdeaChoices(ideas []client.IdeaOut) []Choice

IdeaChoices makes the choices for ChooseSlug from ideas.

type Env

type Env struct {
	// Forge is the forge that hosts the repo in dir, used to name the person.
	Forge func(dir string) forge.Forge
	// Person names the person running Physa in dir; "" when unknown, having
	// said why on stderr.
	Person func(dir string, f forge.Forge, stderr io.Writer) string
	// Start says how an engine is started when none answers.
	Start enginestart.Options
	// Getenv reads the environment: agent sessions, $VISUAL and $EDITOR.
	Getenv func(string) string
	// IsInteractive says whether a person is at the terminal; nil asks
	// output.Interactive about stdin and stdout.
	IsInteractive func() bool
	// Pick and Confirm ask the person at the terminal.
	Pick    func(title string, items []picker.Item) (string, error)
	Confirm func(question string) (bool, error)
	// Stdin is what --from - and --signal-from - read.
	Stdin io.Reader
	// Stdio are the editor's standard input, output and error.
	Stdio [3]*os.File
}

Env is what the idea and pursuit commands share: how they reach the engine, who the person is, and how they ask a person at a terminal. New fills it with the real ones; tests replace fields.

func New

func New(newForge func(dir string) forge.Forge) *Env

New returns the Env of a real run: the forge newForge builds, the person's usual name, the real environment, terminal and pickers.

func (*Env) Agent

func (e *Env) Agent() (string, bool)

Agent names the agent whose session Physa runs inside, if any.

func (*Env) Call

func (e *Env) Call(method string, params, result any) error

Call connects to the engine in the settings directory, starting it when it is not running, and calls method within callTimeout.

func (*Env) ChooseSlug

func (e *Env) ChooseSlug(kind, given string, choices []Choice) (string, error)

ChooseSlug returns the slug of the kind ("idea", "pursuit") a command is about: the one given wins; with none given, a person at a terminal chooses one from choices; anywhere else it is a UsageError listing the choices, in the order given (newest first), or saying there are none.

func (*Env) Edit

func (e *Env) Edit(path string) error

Edit opens path in $VISUAL, else $EDITOR, else vi, on the terminal. The variable may carry arguments, split on spaces.

func (*Env) Ideas

func (e *Env) Ideas(repo string) ([]client.IdeaOut, error)

Ideas lists the repo's ideas, newest first.

func (*Env) Interactive

func (e *Env) Interactive() bool

Interactive is the one decision every idea and pursuit command makes between a person at a terminal (pickers, styles, confirms) and a pipe, CI or an agent (plain text or --json, errors instead of questions).

func (*Env) ReadFrom

func (e *Env) ReadFrom(path string) (string, error)

ReadFrom reads the file at path, or stdin for "-".

func (*Env) Repo

func (e *Env) Repo() (string, error)

Repo returns the absolute root of the repo holding the working directory: the nearest directory upwards with a .git entry.

func (*Env) View

func (e *Env) View(w io.Writer) *View

View makes the View for w, styled when Interactive says a person is there.

func (*Env) Who

func (e *Env) Who(dir string, stderr io.Writer) string

Who names the person running Physa in the repo at dir; "" when unknown, having said why on stderr.

type UsageError

type UsageError struct{ Msg string }

UsageError is a command line that cannot be run as given; Failed prints its message and the command's help.

func (*UsageError) Error

func (e *UsageError) Error() string

type View

type View struct {
	// contains filtered or unexported fields
}

View prints a command's answer: styled with Lip Gloss for a person at a terminal, written through a writer that drops what the output cannot show (so a pipe never gets escapes); plain through output.For otherwise.

func (*View) Fields

func (v *View) Fields(pairs ...[2]string)

Fields prints one "key value" line per pair, keys padded to one width.

func (*View) Line

func (v *View) Line(s string)

Line prints s as it is.

func (*View) Section

func (v *View) Section(name, body string)

Section prints a part's name and its body indented under it.

func (*View) Table

func (v *View) Table(header []string, rows [][]string)

Table prints rows under header in padded columns. Styled, the first column is a slug and the last holds facts.

func (*View) Title

func (v *View) Title(s string)

Title prints s as the answer's title.

Jump to

Keyboard shortcuts

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