[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-6942":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":17,"stars30d":18,"stars90d":16,"forks30d":16,"starsTrendScore":19,"compositeScore":20,"rankGlobal":10,"rankLanguage":10,"license":21,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":22,"hasPages":24,"topics":25,"createdAt":10,"pushedAt":10,"updatedAt":30,"readmeContent":31,"aiSummary":32,"trendingCount":16,"starSnapshotCount":16,"syncStatus":19,"lastSyncTime":33,"discoverSource":34},6942,"swift-argument-parser","apple\u002Fswift-argument-parser","apple","Straightforward, type-safe argument parsing for Swift","https:\u002F\u002Fswiftpackageindex.com\u002Fapple\u002Fswift-argument-parser\u002Fdocumentation",null,"Swift",3722,384,150,106,0,3,18,2,63.06,"Apache License 2.0",false,"main",true,[26,27,28,29],"cli","command-line","flag","option","2026-06-12 04:00:31","# Swift Argument Parser\n\n## Usage\n\nBegin by declaring a type that defines the information\nthat you need to collect from the command line.\nDecorate each stored property with one of `ArgumentParser`'s property wrappers,\nand then declare conformance to `ParsableCommand` and add the `@main` attribute.\n(Note, for `async` renditions of `run`, conform to `AsyncParsableCommand` rather\nthan `ParsableCommand`.)\nFinally, implement your command's logic in the `run()` method.\n\n```swift\nimport ArgumentParser\n\n@main\nstruct Repeat: ParsableCommand {\n    @Flag(help: \"Include a counter with each repetition.\")\n    var includeCounter = false\n\n    @Option(name: .shortAndLong, help: \"How many times to repeat 'phrase'.\")\n    var count: Int? = nil\n\n    @Argument(help: \"The phrase to repeat.\")\n    var phrase: String\n\n    mutating func run() throws {\n        let repeatCount = count ?? 2\n\n        for i in 1...repeatCount {\n            if includeCounter {\n                print(\"\\(i): \\(phrase)\")\n            } else {\n                print(phrase)\n            }\n        }\n    }\n}\n```\n\nThe `ArgumentParser` library parses the command-line arguments,\ninstantiates your command type, and then either executes your `run()` method\nor exits with a useful message.\n\n`ArgumentParser` uses your properties' names and type information,\nalong with the details you provide using property wrappers,\nto supply useful error messages and detailed help:\n\n```\n$ repeat hello --count 3\nhello\nhello\nhello\n$ repeat --count 3\nError: Missing expected argument 'phrase'.\nHelp:  \u003Cphrase>  The phrase to repeat.\nUsage: repeat [--count \u003Ccount>] [--include-counter] \u003Cphrase>\n  See 'repeat --help' for more information.\n$ repeat --help\nUSAGE: repeat [--count \u003Ccount>] [--include-counter] \u003Cphrase>\n\nARGUMENTS:\n  \u003Cphrase>                The phrase to repeat.\n\nOPTIONS:\n  --include-counter       Include a counter with each repetition.\n  -c, --count \u003Ccount>     The number of times to repeat 'phrase'.\n  -h, --help              Show help for this command.\n```\n\n## Documentation\n\nFor guides, articles, and API documentation see the\n[library's documentation on the Web][docs] or in Xcode.\n\n- [ArgumentParser documentation][docs]\n- [Getting Started with ArgumentParser](https:\u002F\u002Fswiftpackageindex.com\u002Fapple\u002Fswift-argument-parser\u002Fdocumentation\u002Fargumentparser\u002Fgettingstarted)\n- [`ParsableCommand` documentation](https:\u002F\u002Fswiftpackageindex.com\u002Fapple\u002Fswift-argument-parser\u002Fdocumentation\u002Fargumentparser\u002Fparsablecommand)\n- [`AsyncParsableCommand` documentation](https:\u002F\u002Fswiftpackageindex.com\u002Fapple\u002Fswift-argument-parser\u002Fdocumentation\u002Fargumentparser\u002Fasyncparsablecommand)\n\n[docs]: https:\u002F\u002Fswiftpackageindex.com\u002Fapple\u002Fswift-argument-parser\u002Fdocumentation\u002Fargumentparser\n\n#### Examples\n\nThis repository includes a few examples of using the library:\n\n- [`repeat`](Examples\u002Frepeat\u002FRepeat.swift) is the example shown above.\n- [`roll`](Examples\u002Froll\u002Fmain.swift) is a simple utility implemented as a straight-line script.\n- [`math`](Examples\u002Fmath\u002FMath.swift) is an annotated example of using nested commands and subcommands.\n- [`count-lines`](Examples\u002Fcount-lines\u002FCountLines.swift) uses `async`\u002F`await` code in its implementation.\n- [`default-as-flag`](Examples\u002Fdefault-as-flag\u002FDefaultAsFlag.swift) demonstrates hybrid options that can work both as flags and as options with values.\n\nYou can also see examples of `ArgumentParser` adoption among Swift project tools:\n\n- [`swift-format`](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-format\u002F) uses some advanced features, like custom option values and hidden flags.\n- [`swift-package-manager`](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-package-manager\u002F) includes a deep command hierarchy and extensive use of option groups.\n\n## Project Status\n\nThe Swift Argument Parser package is source-stable;\nversion numbers follow semantic versioning.\nSource-breaking changes to public API can only land in a new major version.\n\nThe public API of version 1.0.0 of the `swift-argument-parser` package\nconsists of non-underscored declarations that are marked public in the `ArgumentParser` module.\nInterfaces that aren't part of the public API may continue to change in any release,\nincluding the exact wording and formatting of the autogenerated help and error messages,\nas well as the package’s examples, tests, utilities, and documentation.\n\nFuture minor versions of the package may introduce changes to these rules as needed.\n\nWe want this package to quickly embrace Swift language and toolchain improvements that are relevant to its mandate.\nAccordingly, from time to time,\nwe expect that new versions of this package will require clients to upgrade to a more recent Swift toolchain release.\nRequiring a new Swift release will only require a minor version bump.\n\n## Adding `ArgumentParser` as a Dependency\n\nTo use the `ArgumentParser` library in a SwiftPM project,\nadd it to the dependencies for your package and your command-line executable target:\n\n```swift\nlet package = Package(\n    \u002F\u002F name, platforms, products, etc.\n    dependencies: [\n        \u002F\u002F other dependencies\n        .package(url: \"https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-argument-parser\", from: \"1.7.0\"),\n    ],\n    targets: [\n        .executableTarget(name: \"\u003Ccommand-line-tool>\", dependencies: [\n            \u002F\u002F other dependencies\n            .product(name: \"ArgumentParser\", package: \"swift-argument-parser\"),\n        ]),\n        \u002F\u002F other targets\n    ]\n)\n```\n\n### Supported Versions\n\nThe minimum Swift version supported by swift-argument-parser releases are detailed below:\n\nswift-argument-parser | Minimum Swift Version\n----------------------|----------------------\n`0.0.1 ..\u003C 0.2.0`     | 5.1\n`0.2.0 ..\u003C 1.1.0`     | 5.2\n`1.1.0 ..\u003C 1.3.0`     | 5.5\n`1.3.0 ..\u003C 1.7.1`     | 5.7\n`1.8.0 ...`           | 6.0\n","Swift Argument Parser 是一个用于 Swift 语言的命令行参数解析库，它提供了一种直观且类型安全的方式来处理命令行输入。其核心功能包括通过装饰器来定义命令行参数，并自动生成帮助信息和错误提示，支持同步及异步命令执行。该库特别适合于需要构建用户友好型命令行工具的开发者使用场景中，无论是简单的脚本还是复杂的多命令应用都能轻松应对。借助 `ParsableCommand` 和 `AsyncParsableCommand` 协议，开发者可以快速实现具有丰富功能的CLI程序而无需过多关注底层细节。","2026-06-11 03:09:40","top_language"]