Re: Command-line parsing
Re: Command-line parsing
- Subject: Re: Command-line parsing
- From: Carter Allen <email@hidden>
- Date: Wed, 21 Jul 2010 11:01:08 -0600
You might be thinking of DDCLI:
http://www.dribin.org/dave/blog/archives/2008/04/29/ddcli/
I've used it before, and when you're writing an ObjC CLI, it does its job perfectly.
- Carter Allen
On Jul 21, 2010, at 8:54 AM, Fritz Anderson wrote:
> I'm writing a Foundation tool that will take both options and pathname arguments.
>
> If you use NSUserDefaults, you can handle key-value options (-threshold 17) pretty easily, but this has limitations. I don't see how it can be graceful for
>
> * Two-hyphen options (chatty --verbose).
> * Non-value options (ls -a).
> * Single-item key-value options (chatty --verbose=3 -or- chatty -v3).
> * Concatenated options (ls -al)
>
> I also don't know what you do about "normal" arguments (ls -al /Users/fritza) without using NSUserDefaults _and_ running through [[NSProcessInfo processInfo] arguments] with at least a minimal state machine, which defeats the purpose.
>
> Enough complaining. Correct me if I'm wrong.
>
> I remember from 2001 or so that there was an open-source framework inherited from the OpenStep days, that included a helper for getopt(3) sorts of tasks, but for the life of me, I can't remember its name, and I don't know where it would be hosted or whether it would be compatible with today's Foundation framework.
>
> Yes, iterating through [[NSProcessInfo processInfo] arguments] and parsing for myself is the ultimate option, but if it's a solved problem, why make all the mistakes again?
>
> Google doesn't turn up much, beyond the NSUserDefaults trick. Any ideas?
>
> — F
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden