Repolode
apple

apple/swift-argument-parser

A type-safe Swift library for declaring and parsing command-line arguments, options, and flags with auto-generated help.

Estrelas
3,793
Forks
438
Issues abertas
154
Último commit
há 3 dias

O que é?

Swift Argument Parser is a library for building command-line tools in Swift. You declare a type whose stored properties are annotated with property wrappers for flags, options, and positional arguments, then conform it to ParsableCommand or AsyncParsableCommand. The library parses the arguments, instantiates your type, and runs your run() method, or exits with an error message.

Because the parser uses property names, types, and the help text you supply, it generates usage lines, detailed --help output, and error messages without extra code. Commands can be nested into subcommands, and the package includes examples such as a nested math tool and an async/await line counter.

The package follows semantic versioning and requires a minimum Swift toolchain that depends on the release, from Swift 5.1 for early versions up to Swift 6.0 for 1.8.0 and later.

Recursos principais

  • 01Declare flags, options, and positional arguments with property wrappers.
  • 02Generates usage text, detailed help, and error messages automatically.
  • 03Supports nested commands and subcommands.
  • 04Offers async/await support through AsyncParsableCommand.
  • 05Integrates with Swift Package Manager as a dependency.

Casos de uso

  • Building a command-line tool in Swift or on Apple platforms.
  • Adding a structured subcommand hierarchy to an existing Swift CLI.
  • Writing a quick script-style utility that needs typed argument parsing.

Tópicos

Perguntas frequentes

O que é swift-argument-parser?
A type-safe Swift library for declaring and parsing command-line arguments, options, and flags with auto-generated help. Swift Argument Parser is a library for building command-line tools in Swift. You declare a type whose stored properties are annotated with property wrappers for flags, options, and positional arguments, then conform it to ParsableCommand or AsyncParsableCommand. The library parses the arguments, instantiates your type, and runs your run() method, or exits with an error message.
swift-argument-parser é gratuito? Qual é a licença?
swift-argument-parser é open source sob a licença Apache-2.0. Confira os termos da licença antes de usá-lo em produtos comerciais.
swift-argument-parser ainda é mantido?
Manutenção ativa. O último commit de swift-argument-parser foi em 16 de out. de 2026.
Para que posso usar swift-argument-parser?
Building a command-line tool in Swift or on Apple platforms. Adding a structured subcommand hierarchy to an existing Swift CLI. Writing a quick script-style utility that needs typed argument parsing.
Onde consigo swift-argument-parser?
O código-fonte e as instruções de instalação estão no GitHub: https://github.com/apple/swift-argument-parser

Resumo gerado por IA a partir do README do projeto. As estatísticas do GitHub são atualizadas diariamente.

Projetos relacionados