GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - emmicro-us/cpp-optparse: Python's excellent OptionParser in C++

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

87 Commits
87 Commits

Folders and files

NameName
Last commit message
Last commit date
t
t
 
 
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
CMakeLists.txt
CMakeLists.txt
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
OptionParser.cpp
OptionParser.cpp
 
 
OptionParser.h
OptionParser.h
 
 
README.md
README.md
 
 
test.sh
test.sh
 
 
testprog.cpp
testprog.cpp
 
 

Repository files navigation

cpp-optparse

This is yet another option parser for C++. It is modelled after the excellent Python optparse API. Although incomplete, anyone familiar to optparse should feel at home.

  • Copyright (c) 2010 Johannes Weißl
  • License: MIT License

Design decisions

  • Elegant and easy usage more important than speed / flexibility
  • Small size more important than feature completeness, e.g.:
    • No unicode
    • No checking for user programming errors
    • No conflict handlers
    • No adding of new actions

FAQ

  • Why not use getopt/getopt_long?
    • Not C++ / not completely POSIX
    • Too cumbersome to use, would need lot of additional code
  • Why not use Boost.Program_options?
    • Boost not installed on all target platforms (esp. cluster, HPC, ...)
    • Too big to include just for option handling for many projects: 322 *.h (44750 lines) + 7 *.cpp (2078 lines)
  • Why not use tclap/Opag/Options/CmdLine/Anyoption/Argument_helper/...?
    • Similarity to Python desired for faster learning curve

Future work

  • Support nargs > 1?

Example

using optparse::OptionParser;

OptionParser parser = OptionParser() .description("just an example");

parser.add_option("-f", "--file") .dest("filename")
                  .help("write report to FILE") .metavar("FILE");
parser.add_option("-q", "--quiet")
                  .action("store_false") .dest("verbose") .set_default("1")
                  .help("don't print status messages to stdout");

optparse::Values options = parser.parse_args(argc, argv);
vector<string> args = parser.args();

if (options.get("verbose"))
    cout << options["filename"] << endl;

About

Python's excellent OptionParser in C++

Resources

Readme
MIT license
Activity
Custom properties

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.