샘플
args 2.7.0: Build and test a package:args CommandRunner subcommand CLI, telling apart which node reports a UsageException and pinning the option rules that differ from argparse, getopt and clap
검증된 샘플 — pub args 2.7.0: Build and test a package:args CommandRunner subcommand CLI, telling apart which node reports a UsageException and pinning the option…
sha256:d5e47381de03ab961e2135483018d410dd3e1365963e163f552519d3a16f7875
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
dart 3 linux x64 dart 3 dart pub
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| dart 3 · linux alpine/x64 · docker ed25519:a2ec939a4c60e243 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · pub@1 |
2026-08-14 |
케이스
HOW- 목표
- Build and test a package:args CommandRunner subcommand CLI, telling apart which node reports a UsageException and pinning the option rules that differ from argparse, getopt and clap
- 패키지
- 심벌
-
- CommandRunner
- CommandRunner.run
- Command.run
- Command.argResults
- Command.usageException
- UsageException
- ArgParser.addFlag
- ArgParser.addOption
- ArgParserException
- ArgResults.flag
- ArgResults.option
- ArgResults.rest
- 환경
- dart 3
- 생성일
- 2026-08-14T19:59:28Z
컨트랙트
- assert a subcommand runs and the value its run returns comes back out of CommandRunner<int>.run, so the exit code travels as a return value and nothing is printed
- assert no arguments, --help and <command> --help all complete with null after printing usage, so null is a success value and Command.run was never reached
- assert an unknown command is a UsageException whose usage is the runner's, with Global options and Available commands, whose toString is message and usage joined, and whose message gains an edit-distance suggestion block only within the default limit of 2
- assert a parse error inside a subcommand is the same UsageException type carrying that subcommand's usage instead of the command list, while a stray word before the command name is reported by the top-level parser and carries the runner's usage again
- assert a unique prefix of a long option is simply an unknown option, because long names are resolved by exact name or alias and no switch adds prefix matching, while the single-letter abbr and an exact alias both work and the alias stays out of the usage block
- assert a collapsed run of single letters takes its value on the FIRST letter, so -tprod sets the option and -vtprod and -vt prod both fail because a later letter must be a flag, and that an unknown letter has one message alone and a different one inside a run
- assert mandatory: true is enforced during parsing only when the option also declares a callback, and that without one the parse succeeds and leaves the option out of the results entirely
- assert the callback-less mandatory option therefore fails as an ArgumentError from ArgResults.option after the command body has already started, while the same declaration with a callback fails as a UsageException during parsing before run is reached
- assert the required option that behaves the same either way is a null check plus an explicit usageException call, throwing UsageException with that command's usage
- assert addFlag creates --no-x for free, including for a flag that already defaults to false, that negatable: false turns --no-x into an error naming the spelling that was typed rather than the declared flag, and that the usage block renders the difference as --[no-]x
- assert everything after -- lands in rest unparsed so a flag past it does not take effect, and that only the first -- is consumed
- assert a -- before the command name stops the top-level parser before it ever looks the command up, so the command that was asked for is reported as unknown while being suggested back
파일
- csx.json
- lib/cli.dart
- pubspec.lock
- pubspec.yaml
- test/contract_test.dart