Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow marking options with "deprecated" help or visibility #656

Open
grynspan opened this issue Jul 24, 2024 · 3 comments
Open

Allow marking options with "deprecated" help or visibility #656

grynspan opened this issue Jul 24, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@grynspan
Copy link

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

@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:

@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?

⚠️ --send-to-czechoslovakia is deprecated: use --send-to-european-union instead
@grynspan grynspan added the enhancement New feature or request label Jul 24, 2024
@natecook1000
Copy link
Member

This sounds handy, but I don't think there's enough of a consensus around how to display those kinds of messages to implement it as a library feature. You can implement that yourself by:

  • providing both flags
  • using validate() to print a message if sendToCzechslovakia is true
  • using a computed property to make is easy to access sendToEuropeanUnion || sendToCzechslovakia within your command

@rauhul
Copy link
Contributor

rauhul commented Jul 24, 2024

how to display those kinds of messages

Seems like we might need a hook for users to decide how to emit the messages. ideally it would be a build time configuration

@grynspan
Copy link
Author

I can implement it myself, sure. :)

Was suggesting having a baked-in feature with a (semi-)canonical output might be nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants