Documentation
¶
Overview ¶
Package tools discovers and runs user-defined scripts from ~/.config/stool/tools/. Each script is a standalone executable file; metadata (scope/target) is declared via "# stool:key=value" header comments rather than a separate registry file.
Index ¶
- Constants
- func Delete(path string) error
- func Dir() (string, error)
- func New(name string, scope Scope, target Target) (string, error)
- func ReadScript(t Tool) (string, error)
- func SeedBuiltins() error
- func Substitute(script string, p Placeholders) string
- func SubstituteAnswers(script string, answers map[string]string) string
- type Choice
- type Placeholders
- type Question
- type Scope
- type Target
- type Tool
Constants ¶
const ( ScopeSingle Scope = "single" ScopeMulti Scope = "multi" TargetLocal Target = "local" TargetRemote Target = "remote" )
Variables ¶
This section is empty.
Functions ¶
func New ¶
New creates a new tool script file with a shebang and header comments, marked executable, ready to be opened in an editor.
func ReadScript ¶
ReadScript returns the raw, unsubstituted contents of a tool file.
func SeedBuiltins ¶
func SeedBuiltins() error
SeedBuiltins writes the bundled starter tools into ~/.config/stool/tools/ on startup, but never overwrites a file that already exists — so the user's own edits (or deletions) are preserved across upgrades. This is how the `go install`-ed binary ships ready-made tools: they're embedded in the binary and materialized on first run.
func Substitute ¶
func Substitute(script string, p Placeholders) string
Substitute replaces {{domain}}/{{domains}}/{{host}}/{{ip}} in script with the values in p. Tools receive their data this way (placeholders in the script body) rather than as positional arguments.
Types ¶
type Choice ¶
type Choice struct {
Label string // shown to the user
Value string // substituted into the script when chosen
}
Choice is one option for a multiple-choice question.
func PublicKeys ¶
func PublicKeys() []Choice
PublicKeys lists the user's available public keys as choices whose value is the key's full contents. It gathers them from two sources, deduped:
- ~/.ssh/*.pub files
- the running ssh-agent via `ssh-add -L` (covers 1Password, gpg-agent, and others that hold keys without a .pub file on disk)
type Placeholders ¶
type Placeholders struct {
Domain string // single domain (scope=single)
Domains string // all domains, space-joined (scope=multi)
Host string // ssh target alias or user@ip; "" for local
IP string // resolved IP if known
}
Placeholders are the substitution tokens available inside a tool script.
type Question ¶
Question is something stool asks the user before running a tool, then substitutes the answer back into the script. Free-text when Choices is nil.
func ParseQuestions ¶
ParseQuestions scans a tool script for interactive placeholders and returns the distinct questions to ask (deduplicated by key, first prompt wins, in order of first appearance).