parsing command line options
1
Name:
Anonymous
2007-07-01 20:54
ID:+JqMyh4H
Hey there fella's,
I'm writing a small command-line application in C for windows, and I was wondering what the best way to parse command-line optins would be?
2
Name:
Anonymous
2007-07-01 21:20
ID:Zmfa+1R8
DON'T DO IT
3
Name:
Anonymous
2007-07-01 21:20
ID:Zmfa+1R8
DON'T DO IT
4
Name:
Anonymous
2007-07-01 21:25
ID:6rFkiIG4
5
Name:
Anonymous
2007-07-01 22:07
ID:+JqMyh4H
>>4
thanks brah, although it is impossible for me to rewrite for unix, it seems the compiler that im using has getopt.h, so ill see how that goes.
6
Name:
Anonymous
2007-07-02 5:46
ID:e1ul2ThF
>>5
use getopt_long or write your own parser.
I've seen some #defines that do the trick.
7
Name:
Anonymous
2007-07-02 6:08
ID:FhEIBKWM
What is a good way to do it with MSVC, as that doesn't have getopt.
8
Name:
Anonymous
2007-07-02 6:12
ID:/b+7TxzS
>>7
You could parse them. It should be pretty easy if you accept options in the form:
-option [argument]
--option[=argument]
and if you don't accept the old style Unix mess of -fags as shortcut for -f -a -g -s.
9
Name:
Anonymous
2007-07-02 6:48
ID:Heaven
>>1
A complete parser should parse this:
-a b --clong=d -efg -- -h
it's not hard, so write one yourself faggot.
10
Name:
Anonymous
2007-07-02 7:50
ID:Heaven
Getopt is not ENTERPRISE enough. Use a XML configuration file.
11
Name:
Anonymous
2007-07-02 8:10
ID:fGLszCm3
12
Name:
Anonymous
2007-07-02 18:21
ID:Heaven
Just copy getopt.c and getopt.h from some gpl'd project, and include the .h file.
13
Name:
Anonymous
2007-07-02 19:31
ID:DnvD6aje
>>12
ITT we infringe on copyrights.
14
Name:
Anonymous
2007-07-02 19:48
ID:oI7/RC7d
>>13
i thought you were able to yoink source from gpl as long as your project is also GPL?
Anyways, like i said, my compiler comes with getopt.h, so problem solved, and i have finished the app. I just need to make it more enterprise.
15
Name:
Anonymous
2007-07-02 20:40
ID:fGLszCm3
>>14
You're allowed to steal gpl code, it's not like they'll ever find out ;)
16
Name:
Anonymous
2007-07-03 0:42
ID:Heaven
>>13
ITT we realise that someone has already written the best code for the purpose.
17
Name:
Anonymous
2007-07-03 7:29
ID:Heaven
>>16
Then what about popt and all those other stupid getopt libraries?
18
Name:
Anonymous
2009-03-06 6:23
Seen eternity and routinely manipulate the infinites when we conjure the spirits of the computer with my spells and getting paid to do so Enjoy your Flash shit is in perpetual beta requiring updates very few weeks The 3 0 but why Flex Builder 2 0 rem n x x 1 def.
19
Name:
Anonymous
2009-03-06 6:24
lol that is indeed decent for beginners having taught basics to a few day to notice he actually made up the word spelling means come back when you do fvar 0.
20
Name:
Anonymous
2010-11-26 6:57