Giter Site home page Giter Site logo

sirraide / clopts Goto Github PK

View Code? Open in Web Editor NEW
6.0 1.0 0.0 116 KB

Type-safe, compile-time header-only command line options library for C++20

License: MIT License

CMake 1.66% Shell 0.70% C++ 97.64%
cxx command-line-options compile-time header-only cxx20

clopts's People

Contributors

sirraide avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

clopts's Issues

Proper GNU short option parsing

We already sort of support short options, but the way they work is pretty limited atm. Finishing implementing short options entails:

  • Parsing short option clusters (e.g. -la in ls -la).
  • Parsing short option clusters that contain exactly one option that accepts arguments (e.g. -xvf in tar -xvf .... This option must come last (e.g. tar -fvx is not valid), and as a consequence, it need not be separated from its argument by whitespace.
  • Should probably also add an option that lets the user specify whether -- should stop parsing.
  • Actually documenting all of this.
  • multiple<short_option<...>> does not seem to work at the moment.

Add option to ignore or warn on unknown arguments

Something like:

unknown_error // default, obviously
unknown_warn
unknown_ignore

Implement this as a type that stores an enumerator; we could expose the enumerator, but that would mean 1. more things to check, and 2. unknown<unknown_mode::error> is too verbose, and unknown<error> is just namespace pollution, so there’s no particularly good way of doing that...

[Feature] Add option tags and parse state

Basically, it would be nice to have a feature that lets us attach tags to something, similarly to how the -x option works in Clang:

tag<"-x", "Set the file type", std::string>,
positional<"files", "The files to compile", tagged<std::string, "-x">,

Example:

foo -x t1 bar baz -x t2 quux foobar

Content of "files":

{"foo", ""},
{"bar", "t1"},
{"baz", "t1"},
{"quux", "t2"},
{"foobar", "t2"},

Add colours

VLC’s --help and -H printouts look pretty nice; perhaps we could ‘take inspiration’ from that. This would entail:

  • Adding some way of specifying colours, probably through a single colo(u)rs<...> type. Also add some default themes because why not.
  • Adding another builtin option type (like help<>) that adds a --colo(u)r option that allows users to disable/enable colours from the command line. This should probably passed in together with the colour configuration. It would probably be a good idea if all of the colour configuration is handled via the colo(u)rs<...> type, possibly w/ subtypes.
  • Actually implementing the option type in question in the printer, as well as precalculating several help messages.
  • By default, it should use isatty() to determine whether or not to print colours.
  • Add support for 3×256-bit colours (yes, there are ANSI escape codes for that).

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.