Binary Structure CLI Tool
Decode with the full three-word form
Decode with the full three-word form
deno run -A @binstruct/cli png pngFile decode < input.png > struct.json5
Omit the coder when the package has only one
Omit the coder when the package has only one
deno run -A @binstruct/cli arp decode < arp.bin > arp.json5
A local module works the same way, relative to the working directory
A local module works the same way, relative to the working directory
deno run -A @binstruct/cli ./my-package/mod.ts myStruct decode < input.bin > output.json5
Programmatic usage: plan an invocation without performing it
Programmatic usage: plan an invocation without performing it
import { assertEquals } from "@std/assert"; import { planCli } from "@binstruct/cli"; const plan = await planCli(["png", "pngFile", "decode"]); assertEquals(plan.kind, "run"); if (plan.kind === "run") assertEquals(plan.specifier, "jsr:@binstruct/png");
Explains why a package yielded no coders, by reading its module graph.
Discovers the coder factories a package exposes, without importing it.
Explains a failure that only surfaced once the package was imported.
Reports what a resolved specifier points at, before anything is run on it.
Reports whether a name ends in an extension the runtime will load.
Lists the packages of the @binstruct scope, live from JSR.
Main CLI entry point.
Picks the candidate closest to a misspelling, for a "did you mean" line.
Parses command line arguments into the three positionals and the flags.
Works out what an invocation amounts to, without performing it.
Reads a package's discoverable surface out of parsed deno doc --json output.
Reads a package listing out of a parsed JSR scope-packages response.
Returns deno doc's formatted documentation for one exported symbol.
Renders a guidance screen.
Resolves a user-typed package argument to a module specifier.
Renders the shortest form of a specifier that still resolves back to it.
CLI configuration options.
-
blankSlots: readonly string[]
Slots filled with a word that says nothing, named as
<package>and so on. -
coder: string | undefined
Coder name, absent when it is to be inferred or asked for.
-
command: string | undefined
Command word, absent when it is to be asked for.
-
docs: boolean
Print
deno docoutput for the chosen coder instead of running it. -
extraArgs: readonly string[]
Positionals beyond the third, as typed.
-
help: boolean
Print guidance to stdout and exit 0 instead of to stderr and exit 1.
-
package: string | undefined
Package specifier as typed, before
resolveSpecifier. -
unknownFlags: readonly string[]
Flags the parser was given and does not know, as typed.
-
version: boolean
Print version information.
A user-typed package argument and everything derived from it.
-
form: SpecifierForm
The resolution rule that matched.
-
input: string
The argument exactly as the user typed it.
-
short: string
The shortest form that resolves back to
ResolvedSpecifier.specifier, for listings andTRYlines. Equal toshortenSpecifier(specifier), except for a path, where it is the input itself — a path is anchored to the working directory the CLI was started in, and only the typed form still says so. -
shorthand: boolean
Whether the input was shorthand, and therefore expanded.
-
specifier: string
The module specifier to hand to
deno doc.
| { readonly kind: "run"; readonly specifier: string; readonly coder: string; readonly command: CommandName; readonly arityVerified: boolean; readonly notices: readonly string[]; }
What an invocation amounts to, once its arguments are understood.
A command the CLI can carry out.
A single declaration of an exported symbol in deno doc --json output.
-
def: { params?: DenoDocParam[]; returnType?: DenoDocType; }
Kind-specific detail; for functions, the signature.
-
jsDoc: { doc?: string; }
The declaration's JSDoc, when it has one.
-
kind: string
Declaration kind, e.g.
function,variable,interface. -
location: { filename: string; }
Where the declaration lives; the version rides along for JSR specifiers.
The deno doc --json document, narrowed to the parts discovery reads.
-
nodes: Record<string, DenoDocNode>
One entry per documented module, keyed by the module's own URL.
A module entry in deno doc --json output.
-
module_doc: { doc?: string; }
The
@moduleJSDoc of the documented module. -
symbols: DenoDocSymbol[]
Every exported symbol, in declaration order.
A parameter of a declaration in deno doc --json output.
-
kind: string
Binding form:
identifier,assign,rest,objectorarray. -
optional: boolean
Whether the parameter was declared with a trailing
?.
An exported symbol in deno doc --json output.
-
declarations: DenoDocDeclaration[]
One entry per declaration, e.g. one per overload.
-
name: string
The exported name.
A type reference in deno doc --json output.
-
repr: string
Rendered type name, e.g.
Coder. Absent for anonymous forms like unions. -
value: { typeParams?: DenoDocType[]; }
Resolved details, including the type arguments of a generic reference.
A coder factory found in a package's public types.
-
decodedType: string
The
TofCoder<T>, absent when it is an anonymous type such as a union. -
name: string
The exported name, e.g.
pngFile. -
requiredParams: number
Arguments the caller must supply;
0means the CLI can call it directly. -
summary: string
First line of the factory's JSDoc, absent when it is undocumented.
The result of discoverCoders.
A package whose type declarations were read successfully.
| ToolFailure
The result of diagnoseEmptyDiscovery.
Everything one guidance screen says.
-
diagnostic: boolean
Whether the screen reports a failure rather than disclosing the next word.
-
footer: readonly string[]
Trailing lines, e.g. the usage recap
--helpadds. -
header: string
First line, echoing the resolved specifier so shorthand is never invisible.
-
next: GuideNext
The missing word.
-
notes: readonly string[]
Lines shown before
NEXT: what went wrong, or what was inferred. -
options: GuideOptions
The values that word may take.
-
try: readonly string[]
Paste-ready commands one step further along.
The missing word and what it means.
-
meaning: string
One line on what the word selects.
-
word: string
The word, written as it appears in the usage line, e.g.
<coder>.
One legal value of the missing word.
-
detail: string
Short annotation shown in its own column, e.g.
→ PngFile. -
name: string
The word to type, e.g.
png,pngFileordecode. -
summary: string
One-line description, e.g. the first line of the coder's JSDoc.
The options block: every value the missing word may take.
-
empty: string
Line shown in place of an empty list, e.g. why discovery found nothing.
-
heading: string
Block heading, e.g.
PACKAGESorCODERS in png. -
items: readonly GuideOption[]
The legal values, in the order they should be shown.
Where the packages of a ScopeListing came from.
The public surface of a package as read from its type declarations.
-
coders: DiscoveredCoder[]
Coder factories, zero-required-parameter ones first.
-
summary: string
First line of the module JSDoc, absent when the module is undocumented.
-
version: string
Resolved version, when the specifier resolved to a JSR package.
The result of listScopePackages.
-
packages: readonly ScopePackage[]
The scope's published packages, sorted by name, without
@binstruct/cli. -
reason: string
Why the network answer is missing, when it is.
-
source: ListingSource
Where they came from.
Options for listScopePackages.
-
cacheDir: string | null
Directory holding the cache file. Absent means the OS cache directory;
nulldisables the cache in both directions. -
now: number
Current time in milliseconds, for ageing the cache.
-
ttl: number
How long a cached listing is served before a refetch, in milliseconds.
One published package of the scope, as JSR describes it.
-
description: string
JSR's one-paragraph description, empty when the package has none.
-
latestVersion: string
The version a bare
jsr:@binstruct/<name>resolves to today. -
name: string
Short name, e.g.
png; prefix@binstruct/for the JSR coordinate.
Which resolution rule matched an input.
The result of readSymbolDocs.
A deno subprocess that did not produce usable output.
-
code: number
Exit status, absent when the process never started.
-
command: string[]
The argument vector, for a reproducible line in an error message.
-
ok: false
Discriminant: this outcome carries no result.
-
reason: ToolFailureReason
Which environmental condition stopped the tool.
-
specifier: string
The specifier discovery was asked about.
-
stderr: string
The subprocess's stderr, or the message of the error that replaced it.
| "not-spawned"
| "minimum-dependency-age"
| "exited-non-zero"
| "graph-incomplete"
| "timed-out"
Why a deno subprocess spawned by discovery produced no usable output.
Binary Structure CLI Tool
Explains a failure that only surfaced once the package was imported.
Main CLI entry point.
Parses command line arguments into the three positionals and the flags.
Works out what an invocation amounts to, without performing it.
CLI configuration options.
-
blankSlots: readonly string[]
Slots filled with a word that says nothing, named as
<package>and so on. -
coder: string | undefined
Coder name, absent when it is to be inferred or asked for.
-
command: string | undefined
Command word, absent when it is to be asked for.
-
docs: boolean
Print
deno docoutput for the chosen coder instead of running it. -
extraArgs: readonly string[]
Positionals beyond the third, as typed.
-
help: boolean
Print guidance to stdout and exit 0 instead of to stderr and exit 1.
-
package: string | undefined
Package specifier as typed, before
resolveSpecifier. -
unknownFlags: readonly string[]
Flags the parser was given and does not know, as typed.
-
version: boolean
Print version information.
| { readonly kind: "run"; readonly specifier: string; readonly coder: string; readonly command: CommandName; readonly arityVerified: boolean; readonly notices: readonly string[]; }
What an invocation amounts to, once its arguments are understood.
A command the CLI can carry out.