# Commander
**Repository Path**: mirrors_LinusU/Commander
## Basic Information
- **Project Name**: Commander
- **Description**: Compose beautiful command line interfaces in Swift
- **Primary Language**: Unknown
- **License**: BSD-3-Clause
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2022-03-26
- **Last Updated**: 2026-01-10
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# Commander
[](https://travis-ci.org/kylef/Commander)
Commander is a small Swift framework allowing you to craft beautiful command
line interfaces in a composable way.
## Usage
##### Simple Hello World
```swift
import Commander
let main = command { (filename:String) in
print("Reading file \(filename)...")
}
main.run()
```
##### Type-safe argument handling
The closure passed to the command function takes any arguments that
conform to `ArgumentConvertible`, Commander will automatically convert the
arguments to these types. If they can't be converted the user will receive a
nice error message informing them that their argument doesn't match the
expected type.
`String`, `Int`, `Double`, and `Float` are extended to conform to
`ArgumentConvertible`, you can easily extend any other class or structure
so you can use it as an argument to your command.
```swift
command { (hostname:String, port:Int) in
print("Connecting to \(hostname) on port \(port)...")
}
```
##### Grouping commands
You can group a collection of commands together.
```swift
Group {
$0.command("login") { (name:String) in
print("Hello \(name)")
}
$0.command("logout") {
print("Goodbye.")
}
}
```
Usage:
```shell
$ auth
Usage:
$ auth COMMAND
Commands:
+ login
+ logout
$ auth login Kyle
Hello Kyle
$ auth logout
Goodbye.
```
#### Describing arguments
You can describe positional arguments and options for a command to auto-generate help.
This is done by passing in descriptors of these arguments.
For example, for fixed positional arguments with descriptions, you can use:
```swift
command(
Argument("name", description: "Your name"),
Argument("surname", description: "Your surname"),
Argument("count", description: "Number of times to print")
) { name, surname, count in
for _ in 0..