Skip to content

Instantly share code, notes, and snippets.

@udif
Last active May 25, 2016 19:18
Show Gist options
  • Save udif/9a14fa6920bde6dfcb196779dc432bcc to your computer and use it in GitHub Desktop.
Save udif/9a14fa6920bde6dfcb196779dc432bcc to your computer and use it in GitHub Desktop.

Comaprison of getopt()/getopt_long() replacement libraries

At the moment we are concentrating in C++

  • URL - where is this on github
  • Lang - what language is it written in
  • License - GPL/Apache/MIT/BSD/etc. '?' - No license given
  • of commits - How many commits to date

  • Last commit - Date of the last commit
  • single letter - does it support single letter args like getopt()
    • Bundle - the library supports bundling several single letter flags into a single leading '-'
  • multi letter - does it support getopt_long() style args
    • multi - may define more than one name for the same parameter
  • data types - does the library parse for you the argument, e.g. int/string, or is everything considered strings
    • custom - it is possible to define your own classes that handle your own data type, including error checking for legal values
    • generic - use any data type you want; parameter definition is implemented via templates
  • extra args - does it allow extra arguments that are not part of the getopt parameters
  • config method - how the parameter definition API looks like
    • getopt / getopt_long() style
    • varargs containing all the getopt definitions
    • method - a method call for each getopt flag
    • 1method - one call with a single array of all options
    • parse - no separate config; parameter is configured as part of the parsing method call
  • parse method -
    • loop - loop over the arguments like getopt()
    • ptrs - library setup includes pointers/referencesto the variable to be filled for each argument
    • callbacks - library setup includes a callback function for each argument
    • hash - a method call looks up the flag name
    • stream - parse using stream operators on a new command-line-arg stream
  • built-in help - does the library knows how to automatically display a help/usage message? usually requires supplying a description for each option
  • examples - does the library provides a usage example?
  • Unit Tests - Does the library comes with a set of unit tests for all features?
URL Lang License # of commits Last commit single letter multi letter data types extra args config method parse method built-in help examples Unit Tests
wesleygriffin/getoptxx C++14 ? 2 9-Dec-2015 string varargs hash
ryngonzalez/OptionHandler C++ MIT 37 4-May-2013 string vector<string> method hash
xkbeyer/GetOpt C++ MIT 19 22-Mar-2016 string getopt loop
ErichDonGubler/getopt C++11 Boost 19 3-Nov-2015 ✓ bundle ✓ multi string varargs ptrs
r-lyeh/getopt C++11 zlib libpng 1 19-Apr-2016 ✓ multi string parse method
vlofgren/getoptPlusPlus C++ GPL3 11 28-Aug-2011 custom method hash
songgao/flags.hh C++ BSD 3-Clause 7 29-Mar-2016 generic method ptrs
seraasch/getoptpp C++ Boost 70 15-Sep-2015 generic parse stream
iorate/getoptmm C++14 MIT 8 8-Nov-2015 generic? 1method ptrs callbacks
k2ymg/dec_getopt C++ ? 1 10-Feb-2015 bool int double string varargs ptrs callbacks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment