apple / apple/swift-argument-parser

Automatic versioning handling through SwiftPM plugin

Open
#567 2 comments 3 reactions 0 assignees View on GitHub
enhancement
Dominant language
Swift
Stars
3.8k
Forks
411
Avg merge
7d 14h
Merged PRs (30d)
15

Description

Hi,

it's always felt a bit weird to me to have to manually hardcode and maintain the version number as part of my main command, e.g.

```swift
@main
struct Command: ParsableCommand {
static let configuration = CommandConfiguration(
// ...
version: "1.0.0",
// ...
)
}
```

I'd typically have my version stored in git tags *and* the string here and it's a (admittedly) minor pain if I forget to update the version in code and only update the tag.

Swift Package Manager plugins now offer the ability of generating code at compile-time and thus also generate this version information based on the available git repo metadata. There are some packages that already that do just that (see for example [here](https://github.com/elegantchaos/Versionator), [here](https://github.com/DimaRU/PackageBuildInfo), and [here](https://github.com/m-housh/swift-cli-version)). It would be great however to have such a plugin built directly into and distributed as part of swift-argument-parser so that I could optionally automatically reference a version string pulled from my git repo there.

Thanks for considering!

Contributor guide

Open the contributing guide

Research direction

Start by reviewing Swift Package Manager's code-generation plugin support and the linked Versionator, PackageBuildInfo, and swift-cli-version examples. Done would mean an optional plugin distributed with swift-argument-parser can expose a version derived from git metadata for use in CommandConfiguration.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
build-system, cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.