Catalog npm
Back to packageRELEASE DETAILS

2.1.0

npm

@0x-jerry/silver

Let writing CLI like writing document.

Published17 Jul 2026
Direct dependencies15
Transitive dependenciesNot calculated

README

Current package documentation

Silver

Let writing CLI like writing a document.

Install

pnpm i @0x-jerry/silver

Quick Start

import { silver } from "@0x-jerry/silver";

const cli = silver`
v1.0.0 @autocomplete

my-cli [file], A CLI that writes like a document. ${mainAction}

-t --test @type:defaultValue, Test autocomplete.
-o --output @string, Output file path.

up/upgrade <dir> [...extra] #stopEarly, Upgrade something. ${upgradeAction}

  -f --force @bool, Force upgrade.
`;

// Register custom completion types
cli.type("type", () => ["value1", "value2", "value3"]);

function mainAction([file], options) {
  console.log("file:", file, "options:", options);
}

function upgradeAction([dir, ...extra], options) {
  console.log("dir:", dir, "extra:", extra, "options:", options);
}

Syntax Guide

Silver uses a template literal to define your CLI. Here's the full syntax:

Program-level

v1.0.0 @autocomplete @manual
TokenDescription
v1.0.0Version declaration (must be at the top)
@autocompleteEnables complete subcommand for shell autocomplete
@manualPrevents auto-execution; call cli.execute(argv) manually

Command Definition

commandName/alias [param] <reqParam> [...restParam] #stopEarly, Description text. ${actionFn}
PartExampleDescription
NameinstallCommand name (alphanumeric + _)
Aliasinstall/iShorthand alias via /
Optional param[name]Optional positional parameter
Required param<name>Required positional parameter
Rest param[...items]Collects remaining arguments as array
Flag#stopEarlyCommand flag (see below)
Description, Install packages.Text after comma is the description
Action${myFn}Function to call when command is executed

Command flags:

FlagDescription
#stopEarlyStop parsing options after the first non-option argument

Options

-s --string @type, Description.
PartExampleDescription
Short name-sSingle-letter alias
Long name--stringFull option name
Type@stringOption type (see below)
Description, Description.Text after comma

Parameter Types

[@type:name]     // typed optional parameter
<@type:name>     // typed required parameter
[...@type|_files:name]  // typed rest param with file completion

Types are registered via cli.type(name, getValues). Built-in types include bool, boolean, number, string. Special completion types _files and _dirs enable shell-native file/directory completion.

Autocomplete

Set @autocomplete at the program level to enable shell completion.

Shell Support

ShellCommand
zshsource <(your-cli complete zsh)
PowerShellInvoke-Expression (your-cli complete powershell | Out-String)

For persistent setup, add the output to your shell's config file (.zshrc or PowerShell profile).

Custom Completion Types

cli.type("env", () => ["development", "production", "staging"]);

// Async types
cli.type("remote-branch", async () => {
  const res = await fetch("https://api.example.com/branches");
  return res.json();
});

// With descriptions (displayed in some shells)
cli.type("format", () => [
  { label: "json", desc: "JSON output" },
  { label: "yaml", desc: "YAML output" },
]);

Built-in Completion Types

TypeDescription
_filesFile path completion (shell-native)
_dirsDirectory path completion (shell-native)

These can be combined with custom types: @custom|_files.

API

silver (default export)

function silver(template: TemplateStringsArray, ...tokens: any[]): Silver;

Parses the template and optionally auto-executes with process.argv.

Silver class

MethodDescription
type(name, getValues)Register a completion type (sync or async)
execute(argv)Execute the CLI with the given arguments
parse(raw, ...tokens)Parse a template literal programmatically

Exported Types

import {
  silver,
  BuiltinType, // enum: File = '_files', Dir = '_dirs'
  type CompletionGroup, // { name: string, values: string[] }
  type CompletionOutput, // { groups: CompletionGroup[] }
  type Command,
  type CmdOption,
  type CmdParameter,
  type Program,
  type CmdAction,
  type ActionParsedArgs,
  ProgramFlag,
  CommandFlag,
} from "@0x-jerry/silver";

Thanks

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 15

Native requirements
15 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
@0x-jerry/utils
Environment
{
  "local_name": "@0x-jerry/utils",
  "alias": false,
  "peer_metadata": null
}
^6.5.0runtime
minimist
Environment
{
  "local_name": "minimist",
  "alias": false,
  "peer_metadata": null
}
^1.2.8runtime
mustache
Environment
{
  "local_name": "mustache",
  "alias": false,
  "peer_metadata": null
}
^4.2.0runtime
ohm-js
Environment
{
  "local_name": "ohm-js",
  "alias": false,
  "peer_metadata": null
}
^17.5.0runtime
picocolors
Environment
{
  "local_name": "picocolors",
  "alias": false,
  "peer_metadata": null
}
^1.1.1runtime
@0x-jerry/x-release
Environment
{
  "local_name": "@0x-jerry/x-release",
  "alias": false,
  "peer_metadata": null
}
^3.0.5development
@ohm-js/cli
Environment
{
  "local_name": "@ohm-js/cli",
  "alias": false,
  "peer_metadata": null
}
^2.0.1development
@types/bun
Environment
{
  "local_name": "@types/bun",
  "alias": false,
  "peer_metadata": null
}
latestdevelopment
@types/minimist
Environment
{
  "local_name": "@types/minimist",
  "alias": false,
  "peer_metadata": null
}
^1.2.5development
@types/mustache
Environment
{
  "local_name": "@types/mustache",
  "alias": false,
  "peer_metadata": null
}
^4.2.6development
@types/node
Environment
{
  "local_name": "@types/node",
  "alias": false,
  "peer_metadata": null
}
^26.1.1development
@vitest/coverage-v8
Environment
{
  "local_name": "@vitest/coverage-v8",
  "alias": false,
  "peer_metadata": null
}
^4.1.10development
tsdown
Environment
{
  "local_name": "tsdown",
  "alias": false,
  "peer_metadata": null
}
^0.22.4development
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
^6.0.0development
vitest
Environment
{
  "local_name": "vitest",
  "alias": false,
  "peer_metadata": null
}
^4.1.10development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-SaTqXpMZQb35E4wIv0tb088DktPfkHFdHQBUovsit2zEPrBPnonqPiRcey89Mwn3s6vLsGcFLAzFoRZ3TnpxDg==",
  "shasum": "dbf6b31d285edb0f13901ef82d8b1426dcc8c6db",
  "tarball": "https://registry.npmjs.org/@0x-jerry/silver/-/silver-2.1.0.tgz",
  "fileCount": 5,
  "unpackedSize": 52794,
  "attestations": {
    "url": "https://registry.npmjs.org/-/npm/v1/attestations/@0x-jerry%2fsilver@2.1.0",
    "provenance": {
      "predicateType": "https://slsa.dev/provenance/v1"
    }
  },
  "signatures": [
    {
      "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U",
      "sig": "MEUCICkkxhmiA2bNnlBRtsBwoxQLox1OqKoV4LubzDaCEQl/AiEA4SeQxfKvGlYbiswmpR10uojumR2ldwgrvgxXdyDZGAg="
    }
  ]
}

Repository

PENDING
0x-jerry/silver

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 22:16 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:2f8b8eedbbdb93c8f74896c504e93428a13964bc1d38d3db4d481f87332b9957

Other collected versions

2.0.116 Jul1.2.410 Sept1.2.39 Sept1.2.29 Sept1.2.19 Sept1.2.09 SeptView all collected versions →