Repository navigation
Write command names as plain text in CLI output - #2294
Merged
Merged
Conversation
Messages, help and errors name a command the way the docs do, in backticks, and terminals printed the backticks literally. The source keeps them; the output layer now renders them: bold on a terminal with color on, plain text anywhere else (a pipe, a file, NO_COLOR), and plain text in the --output json error object and warning records. The rule is narrow (pkg/ansi/backticks.go): a pair of backticks on one line around up to 200 characters that do not start or end with a space, with no letter or digit outside either backtick. A lone backtick, an empty pair, a run of three, and one inside a word or a quoted value are left as they are. Co-Authored-By: Claude <noreply@anthropic.com>
Coverage Report for CI Build 38598044054Coverage increased (+0.003%) to 57.901%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
This reverts commit f3acec6. Review found the runtime transform unsafe: a % inside a span went through aurora's Sprintf, real backticks in passed-through uv, HTTP and Airflow text were stripped, and copy-paste commands were rewritten. Command names are written as plain text at the source instead, in the commits that follow. Co-Authored-By: Claude <noreply@anthropic.com>
Messages, help and notes named commands, flags and paths the way the docs do, in backticks, and a terminal printed the backticks as they were, as did an error object's json. They are plain text now, at the source: "astro dev start was removed in Astro CLI v2. Use astro local start instead." Where a bare command read ambiguously mid-sentence, the sentence is rephrased rather than quoted. TestMessagesWriteCommandsAsPlainText (internal/archlint) fails on a string literal holding a backtick anywhere in the repo's non-test Go code, except what its backtickAllowed list names: the markdown astro init writes, the upgrade prompt handed to Otto, and one shell-metacharacter set. TestHelpHasNoBackticks renders every help page in every tree and fails on a backtick. Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Conflicts resolved to v2's code, with the backticks dropped from the messages v2 added or reworded: the removed-command stubs' heads and Shorts (deployment, env, env variable link, dev, run), the dev stub's replacement lines, the --login-link guidance and the deploy target refusal. Tests that pinned the backticked text, and namesReplacement in removed_commands_test.go, now read the plain form. Co-Authored-By: Claude <noreply@anthropic.com>
- Name the reserved local deployment name as "the name local is reserved for this machine", quote 'enable' like 'disable' in --development-mode, and spell the af commands that help and errors point to in full, through the target's suggest, instead of as bare fragments. - runs trigger-wait's errors put the cause before the command to run, instead of running the command into it. - The Otto prompt's bring-up clause gets its backticks back: it is markdown for a model and never printed. backtickAllowed exempts it, and AGENTS.md, by declaration name instead of by file. - The source guard reads only the files git tracks. The help guard also reads each flag's usage as written, since pflag hides a backticked word from the rendered page. - The removed-command test asks for a runnable command in the guidance, and the APC dev-stub test for no Use or Convert with line at all. Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The CLI's own messages named commands, flags and paths the way the docs do, in backticks: "
astro dev startwas removed in Astro CLI v2. Useastro local startinstead." A terminal printed the backticks literally, and so did the--output jsonerror object. This PR writes them as plain text at the source:There is no runtime transform. The PR's first commit (a renderer that bolded or stripped backticks at output time) is reverted in the second. Review found it unsafe in four ways:
%inside a span went through aurora's Sprintf;Plain text at the source has none of those problems.
What changed
astro initconversion notes,checknotes, Deployment clone notes, theastro devstub's payloaderrorandnotes), helpShort/Long/flag usage, next steps (astro package), prompts, and removed-command and removed-flag messages. This spanscmd/,internal/,airflow/, and thepkg/*sub-modulesawsauth,checks,container,emfetch,googleauth,imagebuild,instancelocate,instances,localrtandscaffold, pluspkg/httputilandpkg/util. Astro Desktop sees the plain text too, since it imports the sub-modules.setcreates …" became "The set command creates …" in four places (env, deployment and link removal guidance);lslists" became "The ls command lists" (local api), and "listshows" became "The list command shows" (variables);astro local start --dockerthen" became "then use astro local start --docker" (dev stub note);local" became "Drop local from the command";uv run pytestyourself" became "run your tests yourself with uv run pytest";default = true" became "set default = true on a link";.env" became "add a .env line";linknarrows … useget" became "linking narrows … use the get command";workspaceanddomainin pyproject.toml" became "Check the workspace and domain keys in pyproject.toml", with the same change for "sets noworkspace" and "organizationandworkspaceunder [tool.astro]";dockerfileunder [tool.astro]" became "with the dockerfile key under [tool.astro]";if r.Format == FormatJSONpanic text became "branch on r.Format == FormatJSON";astro initnote that lists severalastro link add …commands now joins them with "; " rather than ", ", so one command is not read as running into the next.pkg/scaffold/airflowupgradeprompt.go, and the CLI's owncliUpgradePrompt.BringUpclause in it) stays markdown. It is written for a model and is never printed.docs/*.mdare markdown), and text passed through from uv, Airflow or an API.Guard tests
TestMessagesWriteCommandsAsPlainText(internal/archlint/backticks_test.go) parses every non-test.gofile that git tracks (git ls-files), sub-modules included, so worktrees under.claude/,.gitand untracked scratch files are never read. It fails on any string literal that holds a backtick, and the failure message states the convention. It skipse2e/,*.gen.go,testdata/and the test-helper packagescliouttest/andinstancestest/. Its allowlist,backtickAllowed, is keyed by file, by file and declared const/var name, or by file and literal. It has four entries:pkg/scaffold/templates.go: agentsContent: the AGENTS.md thatastro initwrites into a project, which is markdown;pkg/scaffold/airflowupgradeprompt.go: the prompt handed to Otto, which is markdown for a model and is never printed;cmd/local/upgrade.go: cliUpgradePrompt: the CLI's own words in that prompt;pkg/scaffold/files1x.go, the literal"$*?\"`: the shell metacharacters that make an argument unsafe to repeat unquoted.An entry that no longer matches anything also fails the test.
TestHelpHasNoBackticks(cmd/help_backticks_test.go) renders every help page in every tree fromrootsUnderTest, hidden commands included. It fails on any line with a backtick, which also catches strings assembled at run time. It also reads every flag's usage as written, because pflag takes a backticked word as the flag's value name and drops the backticks from the page.docs/architecture.md: a new "Commands in messages" section under Output states the convention and the two guards, and the help style guide gains a bullet for it.Tests that pinned backticked text were updated in 52 test files, including
e2e/devstub_test.goande2e/convert_test.go.make update-schemaschanged no goldens; they pin shapes, not values.Merge with v2
v2 has since gained #2285, #2291, #2295, #2297, #2300 to #2310. Merging it (a merge commit, no force-push) conflicted in 15 files. Each was resolved to v2's code, with the backticks dropped from the messages v2 added or reworded:
cmd/astro/deployment_removed.goandcmd/astro/env_removed.go: the stubs' heads ("astro deployment %s was removed in Astro CLI v2.", "astro env %s %s was removed in Astro CLI v2.") and Shorts ("Removed in v2 — use astro env …", "… use the set command, which creates or updates").cmd/astro/env_var_link.go: the create stub's Short and guidance.cmd/local/dev.go: the stub's Short, the "Use %s instead" and "Use %s to make a new project here, or %s to convert …" lines, and "Local Airflow now lives under astro local:".cmd/local/run_removed.go: the Short ("Removed in v2 — use " + replaceRunDag).cmd/removed_flags.go: "To log in on another device, use astro login --login-link".internal/deploy/deploy.go: the deploy-target refusal ("astro deploy or --deployment ", "default = true only preselects the prompt, and astro use and %s are for the query commands").The other conflicts (
airflow/docker.go,cmd/apc/deploy.go,cmd/astro/deploy.go,internal/platform/astro/deploy/deploy.go,internal/project/project.go) took v2's side unchanged: v2 had removed or rewritten that code, and its new text already had no backticks.These are the only backticked literals v2 added:
TestMessagesWriteCommandsAsPlainTextfound 16 after the merge, in the 7 files above, and none in v2's other new code. That includes the 1.x/APC messages, the shipcheck and deploy messages, and the local proxy pages, whose HTML templates use<code>and carry no backticks.Tests that pinned the backticked text now read the plain form:
cmd/config_test.gocmd/local/dev_test.gocmd/local/initcmd_test.gocmd/removed_flags_test.go(thet.Skiptext)cmd/removed_commands_test.go:namesReplacementlooked for "`astro "; it now looks for " astro ".Review follow-up
These changes are in a22032a:
pkg/instances: the reserved-name refusal now opens with "the name local is reserved for this machine and is not a deployment".astro deployment update --development-mode: the help quotes 'enable' the way it already quotes 'disable'.astro afmessages that named a command by a bare fragment now print it in full through the target'ssuggest, ashealthdoes:runs trigger-wait's help ("as astro af runs trigger does");dags explore's help;astro env variable export's help now namesastro env variable list -o jsonin full.runs trigger-wait's two failure errors give the cause first and then "Check on it with …", so the command no longer runs into the wrapped error.cmd/removed_commands_test.go:namesReplacementpasses only when the words after "astro " reach a runnable command in the tree, not the root and not a removed or version-gated stub. Text that says there is no replacement also passes.cmd/local/initcmd_test.go: the APC dev-stub text must hold no "Use " and no "Convert with " line.These were re-run after the merge and the review follow-up:
go build ./...andGOOS=windows go build ./...pass.GOOS=windows go vet ./cmd/... ./internal/...passes.make testpasses.make test-submodulespasses exceptpkg/airflowrt'sTestHasProxyConfigured, which fails on the host where it ran. That host has a macOS system proxy (a PAC URL), and the test asserts there is none. This PR does not touchpkg/airflowrt.make test-e2e(tier 0) passes.make lint,make lint-submodules,make lint-e2e,make lint-goosandmake deadcodepass.make update-schemasproduced no diff.Breaking changes
The text of messages changes. A script that greps stderr, or an error object's
error, for a backticked command (`astro local start`) now seesastro local start. The JSON shapes are unchanged.