apple / apple/swift-argument-parser
Retrieving a machine-readable list of possible options and arguments
- Dominant language
- Swift
- Stars
- 3.8k
- Forks
- 411
- Avg merge
- 7d 14h
- Merged PRs (30d)
- 15
Description
### Description
The [vscode-swift](https://github.com/swift-server/vscode-swift) extension recently added support for [creating a new swift project](https://github.com/swift-server/vscode-swift/pull/755). It does so using `swift package init` with some user input to initialize the project with. Right now, it relies on parsing the output from `swift package init --help` to find the list of available project types for the `--type` option. However, this isn't really an ideal solution as the format could presumably change at any point (and has already drastically changed between swift 5.3 and 5.10).
Here's what the output looks like in Swift 5.8:
```
swift package init --help
OVERVIEW: Initialize a new package
USAGE: swift package init
OPTIONS:
--type Package type: (default: library)
library - A package with a library.
executable - A package with an executable.
tool - A package with an executable that uses
Swift Argument Parser. Use this template if you
plan to have a rich set of command-line arguments.
empty - An empty package with a Package.swift manifest.
--name Provide custom package name
--version Show the version.
-h, -help, --help Show help information.
```
It would be nice to have a more reliable output format (e.g. JSON) that contains the enumerations for the `--type` parameter. No additional information is needed beyond what's already available in the output - the extension only needs the enum value as well as a brief description (a human readable label would be nice to include, but is not necessary as the enum value can be parsed rather easily).
Seeing as this is something that might be beneficial for other commands: it might even be a good idea to add this as a feature of swift argument parser. However, I'm raising an issue here first since this is the primary use case for the vscode-swift extension.
### Expected behavior
_No response_
### Actual behavior
_No response_
### Steps to reproduce
_No response_
### Swift Package Manager version/commit hash
_No response_
### Swift & OS version (output of `swift --version && uname -a`)
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.