登录 注册

swift-argument-parser

去点 Star
其他
3,806
Stars
0
Forks
0
Watchers
0
Open Issues
未知
许可证
Swift
语言
创建时间
最近更新

项目能做什么

直观、类型安全的 Swift 命令行参数解析库。
来源:AI 基于仓库事实生成 · 内容以仓库实际 README 为准

使用说明 查看原始 README 原仓库文档

中文使用说明暂未生成。下面保留原仓库 README 摘录,命令与配置均以原文为准。
原始 README 摘录(英文原文,节选前 3000 字符)
# Swift Argument Parser

## Usage

Begin by declaring a type that defines the information
that you need to collect from the command line.
Decorate each stored property with one of `ArgumentParser`'s property wrappers,
and then declare conformance to `ParsableCommand` and add the `@main` attribute.
(Note, for `async` renditions of `run`, conform to `AsyncParsableCommand` rather
than `ParsableCommand`.)
Finally, implement your command's logic in the `run()` method.

```swift
import ArgumentParser

@main
struct Repeat: ParsableCommand {
    @Flag(help: "Include a counter with each repetition.")
    var includeCounter = false

    @Option(name: .shortAndLong, help: "How many times to repeat 'phrase'.")
    var count: Int? = nil

    @Argument(help: "The phrase to repeat.")
    var phrase: String

    mutating func run() throws {
        let repeatCount = count ?? 2

        for i in 1...repeatCount {
            if includeCounter {
                print("\(i): \(phrase)")
            } else {
                print(phrase)
            }
        }
    }
}
```

The `ArgumentParser` library parses the command-line arguments,
instantiates your command type, and then either executes your `run()` method
or exits with a useful message.

`ArgumentParser` uses your properties' names and type information,
along with the details you provide using property wrappers,
to supply useful error messages and detailed help:

```
$ repeat hello --count 3
hello
hello
hello
$ repeat --count 3
Error: Missing expected argument 'phrase'.
Help:  <phrase>  The phrase to repeat.
Usage: repeat [--count <count>] [--include-counter] <phrase>
  See 'repeat --help' for more information.
$ repeat --help
USAGE: repeat [--count <count>] [--include-counter] <phrase>

ARGUMENTS:
  <phrase>                The phrase to repeat.

OPTIONS:
  --include-counter       Include a counter with each repetition.
  -c, --count <count>     The number of times to repeat 'phrase'.
  -h, --help              Show help for this command.
```

## Documentation

For guides, articles, and API documentation see the
[library's documentation on the Web][docs] or in Xcode.

- [ArgumentParser documentation][docs]
- [Getting Started with ArgumentParser](https://swiftpackageindex.com/apple/swift-argument-parser/documentation/argumentparser/gettingstarted)
- [`ParsableCommand` documentation](https://swiftpackageindex.com/apple/swift-argument-parser/documentation/argumentparser/parsablecommand)
- [`AsyncParsableCommand` documentation](https://swiftpackageindex.com/apple/swift-argument-parser/documentation/argumentparser/asyncparsablecommand)

[docs]: https://swiftpackageindex.com/apple/swift-argument-parser/documentation/argumentparser

#### Examples

This repository includes a few examples of using the library:

- [`repeat`](Examples/repeat/Repeat.swift) is the example shown above.
- [`roll`](Examples/roll/main.swift) is a simple utility implemented as a straight-line script.
- [`math`](Examples/math/Math.swift) is an a
阅读完整原文

商业机会分析 AI 生成

Swift CLI 脚手架与 GUI 包装器生成工具

产品构想为基于 ArgumentParser 构建的 CLI 快速生成 macOS 菜单栏小工具、快捷控制面板(GUI)或跨团队分发的配置面板应用。
核心功能解析 ArgumentParser 结构自动生成 SwiftUI 配置界面、参数校验、历史命令执行记录、一键导出为 macOS App、环境变量管理(尚需验证的假设)。
目标用户开发内部开发运维脚本、工程工具的 macOS/iOS 开发团队与独立开发者(AI推测)。
难度/周期中等 · 4-8 周 · 成本:开发机器(Mac)、Xcode、时间成本(已验证事实)。
收费模式独立软件买断制销售、Mac App Store 售卖或团队订阅授权(AI推测)。
竞争风险目标用户普遍偏好直接使用终端,对 CLI 转 GUI 的实际付费意愿可能较弱(尚需验证的假设)。
依据 AI推测

企业级 Swift 研发效能 CLI 工具定制与维护服务

产品构想利用 Swift 与 ArgumentParser 为大型 iOS/macOS 研发团队定制内部工程效率工具(如自动化构建、模块依赖管理、CI/CD 触发工具)。
核心功能定制化命令行工具架构设计、与 Xcode/Fastlane 集成、跨团队参数模板管理、内部二进制分发系统(尚需验证的假设)。
目标用户中大型移动端团队的技术平台组、工程效能团队(AI推测)。
难度/周期高 · 8-16 周 · 成本:人力成本、售前交流成本(AI推测)。
收费模式项目制技术外包咨询费、长期维保费(AI推测)。
竞争风险企业通常倾向于由内部移动基建团队自研,外包需求小且非标(尚需验证的假设)。
依据 尚需验证的假设

Swift 跨平台 CLI 代码生成器与 IDE 辅助插件

产品构想开发针对 VS Code 或 Xcode 的扩展,支持通过图形化/可视化 schema 一键生成符合 ArgumentParser 规范的类型安全代码、测试用例和 Bash/Zsh 自动补全脚本。
核心功能可视化参数设计器、一键生成 @Option/@Flag/@Argument 结构体、自动生成单元测试模版、自动生成 Shell Completion(尚需验证的假设)。
目标用户高频编写 Swift 脚本及 CLI 的后端或工具链开发者(AI推测)。
难度/周期低至中等 · 3-6 周 · 成本:插件发布者账号费用、开发时间成本(已验证事实)。
收费模式插件免费+高级模板/专业生成功能(Freemium)付费买断(AI推测)。
竞争风险库本身 API 已经足够简洁(如 README 所示通过属性包装器直观声明),代码生成器需求可能过于小众且低频(数据支持的判断)。
依据 数据支持的判断
AI 基于仓库公开数据分析生成,含推测成分,不构成收益承诺。
报告会保存到 个人中心

竞品与相似项目 GitHub Search 真实检索

项目中文简介Stars语言
cpisciotta/xcbeautify 中文介绍暂未生成
An xcodebuild formatter
1,556 Swift
hartbit/Yaap 中文介绍暂未生成
Yet Another (Swift) Argument Parser
117 Swift
klonnet23/helloy-word 中文介绍暂未生成
{ "releases": { "2.0.4": [ "[Fixed] Refresh
92 -
Subito-it/Bariloche 中文介绍暂未生成
An argument-parsing library designed for building declarativ
46 Swift
kareman/Moderator 中文介绍暂未生成
A simple, modular command line argument parser in Swift.
21 Swift
dmulholl/argparser 中文介绍暂未生成
An argument-parsing library for Swift.
21 Swift
以上为通过 GitHub 官方 Search API 检索的相似项目,功能差异与优劣势需进一步人工确认,配置 AI 后可生成对比分析。

项目优势与风险

技术成熟度创建于 ,最近推送 ,发布过 46 个 Release
社区活跃Star 3,806 / Fork 0 / Issue 0(数据支持,可自行核实)
许可证未检测到(需人工确认)
主要风险上游项目方向可能变化;同赛道竞争者较多(见竞品表);热度与需求不完全等价

安装与使用

快速开始(以仓库 README 为准)
git clone https://github.com/apple/swift-argument-parser.git
cd swift-argument-parser
# 请阅读仓库 README 获取确切安装步骤(依赖、配置、启动命令)
阅读原仓库文档
术语说明:Docker=应用容器(把程序和依赖打包运行);API Key=调用外部服务的密钥;Git Clone=把仓库代码下载到本地。常见错误:API Key 未配置 / 端口占用 / 数据库连接失败,多数项目在 README 的 Troubleshooting 章节有说明。