Cotix / cReddit

CLI Reddit client written in C. Oh, crossplatform too!
Other
96 stars 14 forks source link

creddit: Implement argument parsing system #60

Closed mkilgore closed 11 years ago

mkilgore commented 11 years ago

This set of patches adds opt.c and opt.h, which implement an argument parsing system. It's extremely similar to getopt_long in that it can parse short and long arguments, but it's not GNU specific and has some extra simple features to make it easy for creddit to use. The bulk of what it does is explained in opt.h, but it basically loops over argv with a list of flags to check for. Flags can either be single character with "-" or strings with "--".

The second patch implements the use of opt.h in main.c. This doesn't break the old system, you can keep using it like this:

./creddit [subreddit] [username] [password]

But it adds a few flags (With more to be added as new features are added): --help : display help --subreddit : subreddit to load-up --username : Username to lgoin as --password : Password for Username.