did-btcr2-js

ADR 130: create Prints Only the Identifier, and validate Has a Quiet Form

Context

In text mode, create printed the identifier on stdout. It also printed a key note on stderr (Using stored key <urn>. or Generated and stored key <urn> (now the active key).) and, on a network with a faucet, a funding hint of four lines. The usual task is “give me the identifier”, and the extra lines hide the answer.

config validate and identifier validate printed the full result as JSON. That is the correct default for a diagnostic command. But a script or a quick check needs only the answer: valid or not, and if not, why.

The global --verbose flag existed, but it only changed the error output. The global --quiet flag only suppressed stderr hints and warnings, and it had no short form.

Decision

In text mode, create prints only the identifier. --verbose adds the key note and the funding hint on stderr.

config validate and identifier validate keep the full result by default. With -q/--quiet, text mode prints a short result on stdout:

Command Text mode Text mode with -q/--quiet
create The identifier only. --verbose adds the key note and the funding hint on stderr. The identifier only
config validate { "ok", "issues" } as JSON OK, else one line for each issue: <path>: <issue>
identifier validate The report as JSON OK, else the failed check: Invalid identifier (<check> check): <detail>

Alternatives

Consequences

Positive. btcr2 create prints one line, the identifier. btcr2 config validate -q and btcr2 identifier validate <did> -q give a one-word answer, and a failure names the problem on one line. The default output of the validate commands stays the same.

Negative. The text output of create changes, so this is a breaking change of the cli (MINOR at 0.x). On a test network, create no longer shows the faucet link. quickstart still prints it. The generate mode of create makes a key with no note. --quiet now changes stdout for two commands.

Tests. The cli tests cover the identifier alone in text mode, the key note with --verbose after the command word, the unchanged JSON envelope, the funding hint only with --verbose (for -t k and -t x --document), the full result of both validate commands by default, OK and the issue lines of config validate with -q and --quiet and exit code 1, OK and the failed check of identifier validate with -q and --quiet, and formatCheckResult in each mode.