ajalt / clikt

Multiplatform command line interface parsing for Kotlin
https://ajalt.github.io/clikt/
Apache License 2.0
2.57k stars 124 forks source link

Add argumentQuoteCharacterPairs command option #520

Closed toasterofbread closed 6 months ago

toasterofbread commented 6 months ago

Adds the argumentQuoteCharacterPairs command option, which is a list of character pairs.

If an argument's first and last characters match one of these pairs, it will always be interpreted as an argument rather than checking if it matches an option. The list is empty by default to prevent breaking existing functionality.

This is allows applications to receive string arguments beginning with -, such as YouTube video IDs in my case.

ajalt commented 6 months ago

Thank you for the contribution; the code looks good and you even wrote docs!

Clikt already supports the POSIX-standard way of specifying arguments that look like options with the -- token, so you can do ./echo -- --disable now and it will work. That has the advantage of not requiring escaping, which I imagine is easy to forget for some folks.

There's also treatUnknownOptionsAsArgs which can be useful if you don't have options you're worried about conflicting with. You could even combine this with different option prefixes to ensure there are never conflicts.

So I appreciate the contribution but I don't think we should add this feature to Clikt.

toasterofbread commented 6 months ago

Ah, didn't know -- was a thing. That should work for me, thanks.