Command line argument library?

This is a discussion on Command line argument library? within the C++ Programming forums, part of the General Programming Boards category; Is there a library out there for C++ which parses and handles command line arguments passed to it? Like the ...

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    271

    Command line argument library?

    Is there a library out there for C++ which parses and handles command line arguments passed to it? Like the optparse module in Python. I'm looking at something called argh(http://iki.fi/bisqwit/) but it has horrible documentation.

  2. #2
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,488
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  3. #3
    MFC killed my cat! manutd's Avatar
    Join Date
    Sep 2006
    Location
    Boston, Massachusetts
    Posts
    870
    Why not just use argc and argv?
    Silence is better than unmeaning words.
    - Pythagoras
    My blog

  4. #4
    Registered User
    Join Date
    Oct 2005
    Posts
    271
    Thanks, Mario! Exactly what I'm looking for.

    Manutd: If you've ever used optparse in Python, you probably would never want to go back to handling command line arguments directly.

  5. #5
    MFC killed my cat! manutd's Avatar
    Join Date
    Sep 2006
    Location
    Boston, Massachusetts
    Posts
    870
    Never even looked at python
    Silence is better than unmeaning words.
    - Pythagoras
    My blog

  6. #6
    Registered User
    Join Date
    Oct 2005
    Posts
    271
    I don't know what kind of programming is your main focus, but if you do a lot of string handling, you really should try Python. And it's not just strings. If you do a lot of mathematical stuff, Python ain't too shabby. It supports big numbers right out of the box and I heard that it is one of the fastest interpreted languages out there (if not the fastest).

  7. #7
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,488
    One of the things you may find annoying in the library is the MultiSwitchArg choice. Personally, I prefer to have something like -V3 parsed, then -V -V -V for those situations where a valued switch makes sense.

    I didn't change the MultiSwitchArg, but added a ValueSwitchArg header to the lib to deal with the former. I've not tested it fully. But if you feel you need something like that, and you don't feel like implementing it yourself (it's quiet easy anyways) let me know and tomorow I'll pass it on.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. VC++ 6 question: browsing into a library
    By maxhavoc in forum Tech Board
    Replies: 4
    Last Post: 09-15-2006, 06:57 AM
  2. Need help with audio library on DOS...
    By Marton79 in forum C Programming
    Replies: 10
    Last Post: 08-25-2006, 12:32 AM
  3. Makefile for a library
    By sirmoreno in forum Linux Programming
    Replies: 5
    Last Post: 06-04-2006, 04:52 AM
  4. Replies: 19
    Last Post: 01-12-2006, 10:04 AM
  5. Replies: 4
    Last Post: 11-12-2002, 05:26 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21