샘플
minimist 1.2.8: parse CLI arguments with string, boolean options, aliases and defaults using minimist
검증된 샘플 — npm minimist 1.2.8: parse CLI arguments with string, boolean options, aliases and defaults using minimist. node 22 · linux alpine/x64 · docker에서…
sha256:6b1429ca854e1f6b53d3c78c0f4943b6814298d81c0ab3c6ad46e7d092d71e96
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 npm
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-08-28 |
케이스
HOW- 목표
- parse CLI arguments with string, boolean options, aliases and defaults using minimist
- 패키지
- 심벌
-
- minimist
- 생성일
- 2026-08-28T05:34:00Z
컨트랙트
- minimist parses long and short boolean flags and supports negation with --no- prefix
- minimist parses string arguments passed with spaces or equal signs
- minimist forces specified option keys to string type and preserves leading zeros
- minimist forces specified option keys to boolean type without consuming following values
- minimist maps option aliases bidirectionally to full names and alias keys
- minimist applies default values for unspecified options without overriding provided values
- minimist collects remaining positional arguments in the _ array and arguments after -- in the -- array
- minimist supports stopEarly to treat all arguments after the first positional argument as positional
파일
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.mjs
- test/contract.mjs
소스
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: parse CLI arguments with string, boolean options, aliases and defaults using minimist
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/minimist@1.2.8
Demonstrate these symbols/APIs:
- minimist
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:225cee59f0e7bb95b6993989dce43dbfeeeea921f588433d2a6bdceca53c103a","contract":["minimist parses long and short boolean flags and supports negation with --no- prefix","minimist parses string arguments passed with spaces or equal signs","minimist forces specified option keys to string type and preserves leading zeros","minimist forces specified option keys to boolean type without consuming following values","minimist maps option aliases bidirectionally to full names and alias keys","minimist applies default values for unspecified options without overriding provided values","minimist collects remaining positional arguments in the _ array and arguments after -- in the -- array","minimist supports stopEarly to treat all arguments after the first positional argument as positional"],"goal":"parse CLI arguments with string, boolean options, aliases and defaults using minimist","kind":"HOW","packages":["pkg:npm/minimist@1.2.8"],"schemaVersion":1,"symbols":["minimist"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/minimist@1.2.8"],"schemaVersion":1,"subject":"pkg:npm/minimist@1.2.8","symbols":["minimist"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-minimist",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-minimist",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"minimist": "1.2.8"
}
},
"node_modules/minimist": {
"version": "1.2.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
"license": "MIT"
}
}
}
{
"name": "sample-minimist",
"version": "1.0.0",
"type": "module",
"private": true,
"license": "MIT-0",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"minimist": "1.2.8"
}
}
{
"schemaVersion": 1,
"goal": "parse CLI arguments with string, boolean options, aliases and defaults using minimist",
"kind": "HOW",
"packages": [
"pkg:npm/minimist@1.2.8"
],
"symbols": [
"minimist"
]
}
import minimist from 'minimist';
/**
* Parse command-line arguments using minimist with options.
* @param {string[]} args Array of argument strings
* @param {object} [opts] Parsing options (string, boolean, alias, default, etc.)
* @returns {object} Parsed argument object
*/
export function parseArgs(args, opts) {
return minimist(args, opts);
}
export { minimist };
export default minimist;
import assert from 'node:assert/strict';
import { minimist, parseArgs } from '../src/index.mjs';
// 1. minimist parses long and short boolean flags and supports negation with --no- prefix
{
const argv = minimist(['-v', '--verbose', '--no-debug', '-x']);
assert.equal(argv.v, true);
assert.equal(argv.verbose, true);
assert.equal(argv.debug, false);
assert.equal(argv.x, true);
}
// 2. minimist parses string arguments passed with spaces or equal signs
{
const argv = parseArgs(['--host', 'example.com', '--port=8080', '-f', 'config.json']);
assert.equal(argv.host, 'example.com');
assert.equal(argv.port, 8080);
assert.equal(argv.f, 'config.json');
}
// 3. minimist forces specified option keys to string type and preserves leading zeros
{
const argv = minimist(['--code', '0123', '--id', '456'], {
string: ['code', 'id']
});
assert.equal(argv.code, '0123');
assert.equal(typeof argv.code, 'string');
assert.equal(argv.id, '456');
assert.equal(typeof argv.id, 'string');
}
// 4. minimist forces specified option keys to boolean type without consuming following values
{
const argv = minimist(['-a', 'true', '-b', 'false', '-c', 'value'], {
boolean: ['a', 'b', 'c']
});
assert.equal(argv.a, true);
assert.equal(argv.b, false);
assert.equal(argv.c, true);
assert.deepEqual(argv._, ['value']);
}
// 5. minimist maps option aliases bidirectionally to full names and alias keys
{
const argv = minimist(['-h', 'localhost', '-p', '3000'], {
alias: {
h: 'host',
p: ['port', 'pnum']
}
});
assert.equal(argv.h, 'localhost');
assert.equal(argv.host, 'localhost');
assert.equal(argv.p, 3000);
assert.equal(argv.port, 3000);
assert.equal(argv.pnum, 3000);
}
// 6. minimist applies default values for unspecified options without overriding provided values
{
const argv = minimist(['--name', 'alice'], {
default: {
name: 'anonymous',
timeout: 5000,
enabled: true
}
});
assert.equal(argv.name, 'alice');
assert.equal(argv.timeout, 5000);
assert.equal(argv.enabled, true);
}
// 7. minimist collects remaining positional arguments in the _ array and arguments after -- in the -- array
{
const argv = minimist(['cmd', 'subcmd', '--opt', 'val', '--', 'extra1', '--flag', 'extra2'], {
'--': true
});
assert.equal(argv.opt, 'val');
assert.deepEqual(argv._, ['cmd', 'subcmd']);
assert.deepEqual(argv['--'], ['extra1', '--flag', 'extra2']);
}
// 8. minimist supports stopEarly to treat all arguments after the first positional argument as positional
{
const argv = minimist(['--bool', 'cmd', '--other', 'value'], {
boolean: ['bool'],
stopEarly: true
});
assert.equal(argv.bool, true);
assert.deepEqual(argv._, ['cmd', '--other', 'value']);
assert.equal(argv.other, undefined);
}
오리진 시더
익명