Step-by-step guide to add a new (one-file-per-command) Glazed command to the remarquee binary, plus how to add a help entry.
remarquee uses Cobra for command routing and Glazed for consistent parameter parsing and structured output. This tutorial shows the exact workflow to add a new command in the “one file per command” layout, wire it into the binary, and create a help entry that shows up in remarquee help.
Glazed’s help system loads Markdown files at runtime from an embedded filesystem. Follow the conventions described in:
glaze help writing-help-entries
glaze help how-to-write-good-documentation-pages
In particular:
Slug (it becomes remarquee help <slug>).## section with a short paragraph that explains the concept.remarquee exposes help in two complementary ways:
--help: usage + flags for a specific command (generated from the Cobra tree and Glazed parameter definitions).remarquee help ...): rich Markdown pages embedded in the binary.You should add both for non-trivial commands: --help for immediate usage, and a help page for narrative context and examples.
Each command lives in its own .go file under cmd/remarquee/cmds/....
Example layout (cloud group):
cmd/remarquee/cmds/cloud/ls.gocmd/remarquee/cmds/cloud/get.gocmd/remarquee/cmds/cloud/put.goPick an existing command file as a template. For rmapi-backed cloud commands, start from:
cmd/remarquee/cmds/cloud/refresh.goA Glazed command typically consists of:
Command struct embedding *cmds.CommandDescriptionglazed.parameter tagsRun(ctx, parsedLayers) for “human output” mode (BareCommand)RunIntoGlazeProcessor(...) for structured mode (GlazeCommand)--with-glaze-outputYou define flags via parameters.NewParameterDefinition(...) and read them via:
parsedLayers.InitializeStruct(layers.DefaultSlug, &Settings{})This keeps defaults, validation, and help text consistent across output modes.
Use cli.BuildCobraCommand to convert the Glazed command into a Cobra command.
For dual-mode commands, use:
cli.WithDualMode(true)cli.WithGlazeToggleFlag("with-glaze-output")This gives you:
--with-glaze-output is set (JSON/YAML/CSV via --output)Command registration happens in the Cobra tree:
cmd/remarquee/main.gocmd/remarquee/cmds/cloud/root.goFor a new cloud command:
cloud.NewCloudCommand()).remarquee/pkg/docremarquee embeds docs from pkg/doc/ and registers them once at startup.
pkg/doc/doc.gopkg/doc/tutorials/*.md (this file is one example)To add a new help page:
pkg/doc/tutorials/ or pkg/doc/topics/SlugThen verify:
go run ./cmd/remarquee help
go run ./cmd/remarquee help remarquee-add-glazed-command
From the remarquee/ repo root:
# Format
gofmt -w cmd/remarquee/cmds/cloud/your-command.go
# Run command help
go run ./cmd/remarquee cloud your-command --help
# If it supports structured output
go run ./cmd/remarquee cloud your-command --with-glaze-output --output json
# Validate help entry
go run ./cmd/remarquee help remarquee-add-glazed-command
Slug will collide at load-time.InitializeStruct so Glazed defaults/validation remain the source of truth.