commands

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AliasToCanonical = map[string]string{
	"h":    "help",
	"?":    "help",
	"q":    "quit",
	"exit": "quit",
	"prog": "program",
	"w":    "workout",
	"ex":   "exercise",
	"l":    "log",
	"hist": "history",
	"tmpl": "template",
	"~":    "home",
}
View Source
var CommandsOrder = []string{"help", "home", "program", "workout", "exercise", "log", "history", "template", "quit"}
View Source
var KeyBindings = []KeyBinding{
	{
		Key:    "↑/↓ k/j",
		Action: "move",
	},
	{
		Key:    "enter",
		Action: "open",
	},
	{
		Key:    "a",
		Action: "add",
	},
	{
		Key:    "s",
		Action: "start",
	},
	{
		Key:    "l",
		Action: "log sets",
	},
	{
		Key:    "v",
		Action: "graph/logs",
	},
	{
		Key:    "t",
		Action: "templates",
	},
	{
		Key:    "p",
		Action: "programs",
	},
	{
		Key:    "f",
		Action: "finish",
	},
	{
		Key:    "e",
		Action: "edit",
	},
	{
		Key:    "d",
		Action: "delete",
	},
	{
		Key:    "b/esc",
		Action: "back",
	},
	{
		Key:    ":",
		Action: "commands",
	},
	{
		Key:    "?",
		Action: "help",
	},
	{
		Key:    "q",
		Action: "quit",
	},
}
View Source
var Registry = map[string]Spec{
	"home": {
		Name:    "home",
		Aliases: []string{"~"},
		Usage:   "home",
		Summary: "navigate to the home screen",
	},
	"help": {
		Name:    "help",
		Aliases: []string{"h", "?"},
		Usage:   "help",
		Summary: "show available commands",
	},
	"quit": {
		Name:    "quit",
		Aliases: []string{"q", "exit"},
		Usage:   "quit",
		Summary: "exit spotr",
	},
	"program": {
		Name:    "program",
		Aliases: []string{"prog"},
		Usage:   "program list | program add <name> | program select <id|name> | program edit <name> | program delete <id|name>",
		Summary: "list, add, select, edit, or delete workout programs",
	},
	"workout": {
		Name:    "workout",
		Aliases: []string{"w"},
		Usage:   "workout list | workout add <name> | workout select <id|name> | workout edit <name> | workout delete <id|name>",
		Summary: "list, add, select, edit, or delete workouts in the active program",
	},
	"exercise": {
		Name:    "exercise",
		Aliases: []string{"ex"},
		Usage:   "exercise list | exercise add <name> [sets] [reps] | exercise select <id|name> | exercise edit <name> [sets] [reps] | exercise delete <id|name> | exercise set <sets> <reps>",
		Summary: "list, add, select, edit, or delete exercises in the active workout",
	},
	"log": {
		Name:    "log",
		Aliases: []string{"l"},
		Usage:   "log start | log add [exercise] <sets> <reps> | log edit <entry-id> <sets> <reps> | log delete <entry-id> | log finish [notes] | log current",
		Summary: "record the active workout session",
	},
	"history": {
		Name:    "history",
		Aliases: []string{"hist"},
		Usage:   "history list [limit] | history show <session-id>",
		Summary: "browse saved workout sessions",
	},
	"template": {
		Name:    "template",
		Aliases: []string{"tmpl"},
		Usage:   "template list | template show <name|path> | template import <name|path> | template workout <template> <workout> | template export [program] [path] | template validate [name|path]",
		Summary: "browse, import, export, and validate templates",
	},
}

Functions

func HandleKeys

func HandleKeys(key string) (cmd string)

func Resolve

func Resolve(cmd Command) (canonical string, ok bool)

Types

type Command

type Command struct {
	Cmd  string
	Args []string
}

func Parse

func Parse(msg string) (Command, bool)

type KeyBinding

type KeyBinding struct {
	Key    string
	Action string
}

type Spec

type Spec struct {
	// Command name (shown in help)
	Name string
	// Alt names
	Aliases []string
	// Usage (example)
	Usage string
	// One line description
	Summary string
}

Jump to

Keyboard shortcuts

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