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 ¶
- func Appetite(n int64) string
- func BadRequest(err error) bool
- func Command(newForge func(dir string) forge.Forge) *cobra.Command
- func Facts(o client.IdeaOut) string
- func Failed(stderr io.Writer, name string, err error) int
- func JSON(fs *pflag.FlagSet, on *bool)
- func String(fs *pflag.FlagSet, name string, v *string)
- func When(s string) string
- func WriteTemp(pattern, md string) (string, error)
- func Written(stderr io.Writer, name string, err error) int
- type Choice
- type Env
- func (e *Env) Agent() (string, bool)
- func (e *Env) Call(method string, params, result any) error
- func (e *Env) ChooseSlug(kind, given string, choices []Choice) (string, error)
- func (e *Env) Edit(path string) error
- func (e *Env) Ideas(repo string) ([]client.IdeaOut, error)
- func (e *Env) Interactive() bool
- func (e *Env) ReadFrom(path string) (string, error)
- func (e *Env) Repo() (string, error)
- func (e *Env) View(w io.Writer) *View
- func (e *Env) Who(dir string, stderr io.Writer) string
- type UsageError
- type View
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BadRequest ¶
BadRequest reports whether err is the engine refusing what was asked, as opposed to a fault.
func Command ¶
Command returns the idea group, naming people through the forge newForge builds for a repo.
func Facts ¶
Facts says where an idea stands: its latest pursuit's state, or that it was never pursued.
func Failed ¶
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 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 ¶
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.
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 ¶
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 ¶
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) Call ¶
Call connects to the engine in the settings directory, starting it when it is not running, and calls method within callTimeout.
func (*Env) ChooseSlug ¶
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 ¶
Edit opens path in $VISUAL, else $EDITOR, else vi, on the terminal. The variable may carry arguments, split on spaces.
func (*Env) Interactive ¶
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) Repo ¶
Repo returns the absolute root of the repo holding the working directory: the nearest directory upwards with a .git entry.
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.