Exemplo
clap_builder 4.6.6: clap_builder
Amostra verificada para cargo clap_builder 4.6.6: clap_builder. O contrato rodou em rust 1 · linux alpine/x64 · docker e passou.
sha256:feb717b174ed116cf7e1efba1e2874ef340781114b8a5cc23a91974548a6a90d
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 1
- Chaves de assinatura que o compilaram
- 1
Ambiente declarado
linux · alpine · musl x64 cargo
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| 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-10-11 |
Caso
HOW- Objetivo
- verify clap_builder in pkg:cargo/clap_builder@4.6.6
- Pacotes
- Símbolos
-
- clap_builder
- Criado
- 2026-10-11T19:48:54Z
Contrato
- Command and Arg builder constructs flags, options, and positional arguments
- try_get_matches_from parses valid inputs and respects default values and flags
- PossibleValuesParser validates allowed choices and rejects invalid values
- Missing required positional argument returns MissingRequiredArgument error
- Unknown argument returns UnknownArgument error
- Subcommands are recognized and dispatch sub-arguments correctly
Arquivos
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- spec.json
- src/lib.rs
- test/contract.rs
Código-fonte
# 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 clap_builder in pkg:cargo/clap_builder@4.6.6
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/clap_builder@4.6.6
Demonstrate these symbols/APIs:
- clap_builder
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:58dd27493443926e4883f8dae4620b5e0c7c46890f0159f8a99d4a9ca475e64e","contract":["Command and Arg builder constructs flags, options, and positional arguments","try_get_matches_from parses valid inputs and respects default values and flags","PossibleValuesParser validates allowed choices and rejects invalid values","Missing required positional argument returns MissingRequiredArgument error","Unknown argument returns UnknownArgument error","Subcommands are recognized and dispatch sub-arguments correctly"],"goal":"verify clap_builder in pkg:cargo/clap_builder@4.6.6","kind":"HOW","packages":["pkg:cargo/clap_builder@4.6.6"],"schemaVersion":1,"symbols":["clap_builder"]},"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","symbols":["clap_builder"],"verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify clap_builder in pkg:cargo/clap_builder@4.6.6",
"kind": "HOW",
"packages": [
"pkg:cargo/clap_builder@4.6.6"
],
"symbols": [
"clap_builder"
]
}
//! Clean-room verification sample for clap_builder.
pub use clap_builder::*;
use clap_builder::builder::PossibleValuesParser;
use clap_builder::error::ErrorKind;
use clap_builder::{Arg, ArgAction, Command};
fn main() {
// 1. Command and Arg builder constructs flags, options, and positional arguments
let cmd = Command::new("testapp")
.version("1.0.0")
.about("A test CLI application using clap_builder")
.args_conflicts_with_subcommands(true)
.arg(
Arg::new("verbose")
.short('v')
.long("verbose")
.action(ArgAction::Count)
.help("Verbosity level"),
)
.arg(
Arg::new("config")
.short('c')
.long("config")
.action(ArgAction::Set)
.default_value("config.toml")
.help("Configuration file path"),
)
.arg(
Arg::new("mode")
.short('m')
.long("mode")
.action(ArgAction::Set)
.value_parser(PossibleValuesParser::new(["fast", "safe"]))
.help("Execution mode"),
)
.arg(
Arg::new("input")
.action(ArgAction::Set)
.required(true)
.help("Input file to process"),
)
.subcommand(
Command::new("run")
.about("Run the task")
.arg(
Arg::new("dry-run")
.long("dry-run")
.action(ArgAction::SetTrue),
),
);
// 2. try_get_matches_from parses valid inputs and respects default values and flags
let matches = cmd
.clone()
.try_get_matches_from(vec!["testapp", "-vv", "input.txt"])
.expect("should parse valid arguments");
assert_eq!(matches.get_count("verbose"), 2);
assert_eq!(
matches.get_one::<String>("config").map(String::as_str),
Some("config.toml")
);
assert_eq!(
matches.get_one::<String>("input").map(String::as_str),
Some("input.txt")
);
assert_eq!(matches.get_one::<String>("mode"), None);
// 3. PossibleValuesParser validates allowed choices
let mode_matches = cmd
.clone()
.try_get_matches_from(vec!["testapp", "--mode", "fast", "input.txt"])
.expect("fast is a valid mode");
assert_eq!(
mode_matches.get_one::<String>("mode").map(String::as_str),
Some("fast")
);
let invalid_mode = cmd
.clone()
.try_get_matches_from(vec!["testapp", "--mode", "invalid", "input.txt"]);
assert!(invalid_mode.is_err());
assert_eq!(invalid_mode.unwrap_err().kind(), ErrorKind::InvalidValue);
// 4. Missing required positional argument returns MissingRequiredArgument error
let missing_input = cmd.clone().try_get_matches_from(vec!["testapp"]);
assert!(missing_input.is_err());
assert_eq!(
missing_input.unwrap_err().kind(),
ErrorKind::MissingRequiredArgument
);
// 5. Unknown argument returns UnknownArgument error
let unknown_arg = cmd
.clone()
.try_get_matches_from(vec!["testapp", "--nonexistent", "input.txt"]);
assert!(unknown_arg.is_err());
assert_eq!(
unknown_arg.unwrap_err().kind(),
ErrorKind::UnknownArgument
);
// 6. Subcommands are recognized and dispatch sub-arguments correctly
let subcmd_matches = cmd
.clone()
.try_get_matches_from(vec!["testapp", "run", "--dry-run"])
.expect("subcommand run should parse");
let (sub_name, sub_matches) = subcmd_matches.subcommand().unwrap();
assert_eq!(sub_name, "run");
assert!(sub_matches.get_flag("dry-run"));
println!("All clap_builder contract assertions passed successfully.");
}
Seeder de origem
anônimo