apple / apple/swift-argument-parser

Allow marking options with "deprecated" help or visibility

Open
#656 8 comments 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
Swift
Stars
3.8k
Forks
411
Avg merge
7d 14h
Merged PRs (30d)
15

Description

Let's say my CLI tool has an old option that's no longer valid:

```swift
@Option
public var sendToCzechslovakia = false
```

Since Czechoslovakia doesn't exist anymore, I've replace it with `sendToEuropeanUnion`, and I want to inform folks still using it to change their command-line incantations. Wouldn't it be nice if I could write:

```swift
@Option(help: .deprecated("Use --send-to-european-union instead"))
public var sendToCzechslovakia = false
```

And have it automatically be _hidden_ and emit some sort of diagnostic message to `stderr`?

```sh
⚠️ --send-to-czechoslovakia is deprecated: use --send-to-european-union instead
```

Contributor guide

Open the contributing guide

Research direction

Start at the @Option entry point and trace how help visibility and command-line diagnostics are handled. Done means the proposed .deprecated(...) form hides the option and emits a warning to stderr directing users to the replacement option.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.