Giter Club home page Giter Club logo

dimcli's Introduction

dimcli

msvc 2015, msvc 2017 gcc 6, gcc 7, clang 3.6, clang 5.0 test coverage
AppVeyor Status Travis Status codecov

C++ command line parser toolkit for kids of all ages.

  • GNU style command lines (-o, --output=FILE, etc.)
  • parses directly to any supplied (or implicitly created) variable that is:
    • default constructible
    • copyable
    • assignable from string, has an istream extraction operator, or has a specialization of Cli::fromString<T>()
  • help generation
  • option definitions can be scattered across multiple files
  • git style subcommands
  • response files (requires <filesystem> support)
  • works whether exceptions and RTTI are enabled or disabled

Documentation

Check out the wiki, you'll be glad you did! Contains thorough documentation with many examples. Or click here if you prefer it all on a single page.

Include in Your Project

Copy source directly into your project

All you need is:

  • libs/dimcli/cli.h
  • libs/dimcli/cli.cpp

Using vcpkg on Windows

  • vcpkg install dimcli

Using cmake

Get the latest snapshot: dimcli 4.1.0

Build it (this example uses Visual C++ 2015 to install a 64-bit build to c:\dimcli on a windows machine):

  • cmake .. -DCMAKE_INSTALL_PREFIX=c:\dimcli -G "Visual Studio 14 2015 Win64"
  • cmake --build .
  • ctest -C Debug
  • cmake --build . --target install

Working on the dimcli Project

  • Prerequisites
    • install cmake >= 3.6
    • install Visual Studio 2015
      • include the "Github Extension for Visual Studio" (if you care)
      • include git
  • Make the library
  • Test
    • ctest -C Debug
  • Visual Studio 2015
    • open dimcli\dimcli.sln (not the one in dimcli\build\dimcli.sln) for github integration to work

Random Thoughts

Why not a single header file?

  • On large projects with many binaries (tests, utilities, etc) it's good for compile times to move as much stuff out of the headers as you easily can.
  • Inflicting <Windows.h> (and to a much lesser extent <termios.h> & <unistd.h>) on all clients seems a bridge too far.

Sources of inspiration:

  • LLVM's CommandLine module
  • click - Python command line interface creation kit
  • My own bad experiences

Things that were harder than expected:

  • parsing command lines with bash style quoting
  • response files - because of the need to transcode UTF-16 on windows
  • password prompting - there's no standard way to disable console echo :(
  • build system - you can do a lot with cmake, but it's not always easy

Other interesting c++ command line parsers:

dimcli's People

Contributors

gknowles avatar qix- avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.