feat(cli): add --json output to text view and text set#110
Merged
Conversation
Mirrors PR #76: text was the last on-chain namespace without machine-readable output. Adds --json to both subcommands; the underlying viewDomainText and setDomainText now return structured TextViewResult / TextSetResult. JSON output shapes: dotns text view <name> <key> --json → { domain, key, exists, owner, value } dotns text set <name> <key> <value> --json → { ok: true, domain, key, value, txHash } Errors emit { error: "<message>" } on stderr with exit code 1, same as register/content/pop. Removes the legacy piped-stdout fallback in 'text view' (output rerouted to stderr when stdout was a pipe) — superseded by --json. Non-piped, non-json behaviour is unchanged. Tests: textHelp (unchanged) + new textJson unit (3 tests) + 4 new --json integration tests in tests/integration/text/. All 163 unit tests pass.
CI Summary
Release - PassedTest this PR Download artifact (GitHub CLI required): gh run download 24953966467 -n cli-release-0.0.0-pr.110 -R paritytech/dotns-sdkInstall globally: npm install -g ./parity-dotns-cli-0.0.0-pr.110.tgzVerify: dotns --helpDeploy Example — Passed
Labelspkg: cli, type: test Test - Passed163 passed, 0 failed across 163 tests. |
andrew-ifrita
approved these changes
Apr 28, 2026
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.
Summary
Mirrors #76 for the
textnamespace — the last on-chain CLI commands that didn't have machine-readable output. Unblocksbulletin-deploy#173 (set name + description text records at deploy time).Follows the exact pattern that #76 established for
register/content/pop:getJsonFlag/maybeQuiet/emitJsonResult/handleCommandErrorfromjsonHelpers.ts.viewDomainText/setDomainTextnow return structured results (TextViewResult/TextSetResult) — same shiftviewDomainContentHash/setDomainContentHashdid in feat(cli): add --json output to register, content, and pop commands #76.--jsonflag suppresses chalk/ora output viawithCapturedConsole.process.argv.includes("--json")inprogram.ts, so it's silent under--json.JSON output shapes
Reads return data directly (no
okfield); writes return{ ok: true, ... }. Matches the envelope convention documented injsonHelpers.ts.Behaviour change worth flagging
text viewpreviously had a manual piped-stdout fallback: when stdout was a pipe, all chalk output got rerouted to stderr and the bare value was written to stdout, sodotns text view foo bar | xargs ...would just receive the value. That hack is removed — it predated--jsonand conflicted with the new flag (the redirect would hijack the JSON envelope). Scripted users should now use--jsonand parse thevaluefield. The non-piped, non-json TTY experience is unchanged.Tests
tests/unit/text/textJson.test.ts(3 tests):--jsonflag in help output for both subcommands + JSON error envelope for the pre-chain--mnemonic+--key-urimutex. MirrorscontentJson.test.ts.--jsoncases appended totests/integration/text/text.test.ts(4 tests): registered-domain happy path for view/set, unregistered-domain returningexists: false(view) and JSON error (set). Mirrors the--jsonblock at the bottom ofcontent.test.ts.bun test tests/unit/→ 163/163 pass (was 159; +4 from this PR — 3 new + the 1 textHelp test count is unchanged but textJson adds 3, totaling +4? actually +4 unit assertions across the 3 tests; verified locally).bun run build→ green.bun run lint→ clean.bun run format→ clean.bun run typecheck→ 47 pre-existing errors (same count onmain); zero introduced by this PR.Scope
Deliberately excluded from this PR — should be follow-ups:
account address,account info,account map— self-contained namespace, separate concern from text records.auth set/list/use/remove/clear— keystore management, involves interactive password prompts; needs its own design pass.Closes the upstream gap noted in bulletin-deploy PR #180 (
### #173 / text records — NOT in this PR).