샘플
clap_builder 4.6.6
검증된 샘플 — cargo clap_builder 4.6.6. rust 1 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: Command builder creates commands with name, version, and about…
sha256:8832fb7586e6dc8f66f61e903de606c00531af4a5c89a607211e4f1cbdc1b42a
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux · alpine · musl x64 cargo
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| rust 1 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · cargo@1rust:1-alpine@sha256:a10e64dd139b… |
2026-09-19 |
케이스
HOW- 목표
- verify pkg:cargo/clap_builder@4.6.6
- 생성일
- 2026-09-18T23:48:09Z
컨트랙트
- Command builder creates commands with name, version, and about metadata
- Arg builder adds positional and flag arguments with default actions
- Command validates required arguments and returns MissingRequiredArgument error
- Subcommands parse hierarchical command lines and expose nested matches
- Arg with SetTrue action operates as a boolean toggle flag
- Arg with default value supplies fallback when argument is omitted
파일
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- spec.json
- src/lib.rs
- test/contract.rs
소스
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "anstream"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
"is_terminal_polyfill",
"utf8parse",
]
[[package]]
name = "anstyle"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000"
[[package]]
name = "anstyle-parse"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e"
dependencies = [
"utf8parse",
]
[[package]]
name = "anstyle-query"
version = "1.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"
dependencies = [
"windows-sys",
]
[[package]]
name = "anstyle-wincon"
version = "3.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"
dependencies = [
"anstyle",
"once_cell_polyfill",
"windows-sys",
]
[[package]]
name = "clap_builder"
version = "4.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b48fea5a88e9ae728a2dcbedbfc0e730f7d60da42e1cb049a83c9fb8b789889"
dependencies = [
"anstream",
"anstyle",
"clap_lex",
"strsim",
]
[[package]]
name = "clap_lex"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c133bc6a41be0d194c306b5506d15e6feeea7b1d6604bd3f8310dfb2ca96486"
[[package]]
name = "colorchoice"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570"
[[package]]
name = "is_terminal_polyfill"
version = "1.70.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"
[[package]]
name = "once_cell_polyfill"
version = "1.70.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
[[package]]
name = "sample-clap-builder"
version = "1.0.0"
dependencies = [
"clap_builder",
]
[[package]]
name = "strsim"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "utf8parse"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
[[package]]
name = "windows-link"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
[[package]]
name = "windows-sys"
version = "0.61.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
dependencies = [
"windows-link",
]
[package]
name = "sample-clap-builder"
version = "1.0.0"
edition = "2021"
publish = false
[dependencies]
clap_builder = "=4.6.6"
[[bin]]
name = "contract"
path = "test/contract.rs"
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: verify pkg:cargo/clap_builder@4.6.6
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/clap_builder@4.6.6
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:cd9aa2a2831e72b7009a504549fc0b5201e61b3bbe334e824adbcf481beb46b2","contract":["Command builder creates commands with name, version, and about metadata","Arg builder adds positional and flag arguments with default actions","Command validates required arguments and returns MissingRequiredArgument error","Subcommands parse hierarchical command lines and expose nested matches","Arg with SetTrue action operates as a boolean toggle flag","Arg with default value supplies fallback when argument is omitted"],"goal":"verify pkg:cargo/clap_builder@4.6.6","kind":"HOW","packages":["pkg:cargo/clap_builder@4.6.6"],"schemaVersion":1},"contractCommand":["cargo","run","--offline"],"environment":{"arch":"x64","distro":"alpine","ecosystem":"cargo","libc":"musl","os":"linux","packageManager":"cargo","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/clap_builder@4.6.6"],"schemaVersion":1,"subject":"pkg:cargo/clap_builder@4.6.6","verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify pkg:cargo/clap_builder@4.6.6",
"kind": "HOW",
"packages": [
"pkg:cargo/clap_builder@4.6.6"
]
}
//! Clean-room verification sample for clap_builder.
pub use clap_builder::*;
use clap_builder::{Arg, ArgAction, Command};
fn main() {
// 1. Command builder creates commands with name, version, and about metadata
let cmd = Command::new("demo")
.version("1.0.0")
.about("A demonstration CLI tool");
assert_eq!(cmd.get_name(), "demo");
assert_eq!(cmd.get_version(), Some("1.0.0"));
assert_eq!(cmd.get_about().map(|a| a.to_string()), Some("A demonstration CLI tool".to_string()));
// 2. Arg builder adds positional and flag arguments with default actions
let cmd = Command::new("testapp")
.arg(Arg::new("name").required(true).index(1))
.arg(Arg::new("verbose").short('v').long("verbose").action(ArgAction::Count))
.arg(Arg::new("output").short('o').long("output").action(ArgAction::Set));
let matches = cmd.try_get_matches_from(vec!["testapp", "alice", "-vvv", "-o", "result.txt"]).unwrap();
assert_eq!(matches.get_one::<String>("name").map(|s| s.as_str()), Some("alice"));
assert_eq!(matches.get_count("verbose"), 3);
assert_eq!(matches.get_one::<String>("output").map(|s| s.as_str()), Some("result.txt"));
// 3. Command validates required arguments and returns MissingRequiredArgument error
let cmd = Command::new("testapp")
.arg(Arg::new("name").required(true));
let err = cmd.try_get_matches_from(vec!["testapp"]).unwrap_err();
assert_eq!(err.kind(), clap_builder::error::ErrorKind::MissingRequiredArgument);
// 4. Subcommands parse hierarchical command lines and expose nested matches
let root = Command::new("git")
.subcommand(
Command::new("clone")
.arg(Arg::new("repo").required(true))
);
let matches = root.try_get_matches_from(vec!["git", "clone", "https://example.com/repo.git"]).unwrap();
let (sub_name, sub_matches) = matches.subcommand().unwrap();
assert_eq!(sub_name, "clone");
assert_eq!(sub_matches.get_one::<String>("repo").map(|s| s.as_str()), Some("https://example.com/repo.git"));
// 5. Arg with SetTrue action operates as a boolean toggle flag
let cmd = Command::new("flagtest")
.arg(Arg::new("flag").long("dry-run").action(ArgAction::SetTrue));
let matches = cmd.clone().try_get_matches_from(vec!["flagtest", "--dry-run"]).unwrap();
assert_eq!(matches.get_flag("flag"), true);
let matches_absent = cmd.try_get_matches_from(vec!["flagtest"]).unwrap();
assert_eq!(matches_absent.get_flag("flag"), false);
// 6. Arg with default value supplies fallback when argument is omitted
let cmd = Command::new("deftest")
.arg(Arg::new("port").long("port").default_value("8080"));
let matches = cmd.try_get_matches_from(vec!["deftest"]).unwrap();
assert_eq!(matches.get_one::<String>("port").map(|s| s.as_str()), Some("8080"));
println!("All clap_builder contract assertions passed successfully.");
}
오리진 시더
익명