GBCli icon indicating copy to clipboard operation
GBCli copied to clipboard

Short options as strings

Open victor opened this issue 10 years ago • 3 comments

I find that using chars for the short options, while technically correct, is a bit convoluted, specially since they are later converted to NSStrings anyway. I'd request to have additional methods in which short options are declared as NSStrings, as that would make them more usable from Swift (where getting hold of a single char is a pain)

victor avatar Dec 08 '14 07:12 victor

Agree. It makes it difficult to setup short option in Swift. On the other hand using char is nice in Objective-C. Need to come up with nice implementation for both, without introducing another set of registration methods. Also don't want to break existing implementation. Perhaps adding new registration method that would accept "registration object" which would describe all parameters would be nice and future proof (currently there could be two subclasses, one taking char, one string for example).

tomaz avatar Dec 16 '14 10:12 tomaz

What about adding a convenience registration method that takes a string and picks the first char, calling the other method with it? That would be easy to implement in ObjC, and convenient to use from Swift. You can implement it in a category only imported when needed, so as not to pollute the namespace.

El 16/12/2014, a les 11:33, tomaz [email protected] va escriure:

Agree. It makes it difficult to setup short option in Swift. On the other hand using char is nice in Objective-C. Need to come up with nice implementation for both, without introducing another set of registration methods. Also don't want to break existing implementation. Perhaps adding new registration method that would accept "registration object" which would describe all parameters would be nice and future proof (currently there could be two subclasses, one taking char, one string for example).

— Reply to this email directly or view it on GitHub.

victor avatar Dec 16 '14 17:12 victor

That's exactly how I meant to implement it, but don't just want to add another method. Instead I'm aiming for more flexible and future proof approach.

tomaz avatar Dec 16 '14 18:12 tomaz