All Projects → ggabriel96 → opzioni

ggabriel96 / opzioni

Licence: BSL-1.0 license
The wanna-be-simplest command line arguments library for C++

Programming Languages

C++
36643 projects - #6 most used programming language
Meson
512 projects
Makefile
30231 projects

Projects that are alternatives of or similar to opzioni

Compile Time Regular Expressions
A Compile time PCRE (almost) compatible regular expression matcher.
Stars: ✭ 2,144 (+7293.1%)
Mutual labels:  constexpr, cpp20
fixed string
C++17 string with fixed size
Stars: ✭ 64 (+120.69%)
Mutual labels:  constexpr, cpp20
uninttp
A universal type for non-type template parameters for C++20 or later.
Stars: ✭ 16 (-44.83%)
Mutual labels:  constexpr, cpp20
freecli
Command line parsing library using Free Applicative
Stars: ✭ 29 (+0%)
Mutual labels:  options, arguments
RTX-Mesh-Shaders
Different mesh shading techniques using the NVIDIA RTX (Turing) technology.
Stars: ✭ 84 (+189.66%)
Mutual labels:  cpp20
NSE-Stock-Scanner
National Stock Exchange (NSE), India based Stock screener program. Supports Live Data, Swing / Momentum Trading, Intraday Trading, Connect to online brokers as Zerodha Kite, Risk Management, Emotion Control, Screening, Strategies, Backtesting, Automatic Stock Downloading after closing, live free day trading data and much more
Stars: ✭ 78 (+168.97%)
Mutual labels:  options
tau
A Micro (1k lines of code) Unit Test Framework for C/C++
Stars: ✭ 121 (+317.24%)
Mutual labels:  cpp20
cpp20-internet-client
An HTTP(S) client library for C++20.
Stars: ✭ 34 (+17.24%)
Mutual labels:  cpp20
market-monitor
Interactive app to monitor market using Python
Stars: ✭ 20 (-31.03%)
Mutual labels:  options
BackportCpp
Library of backported modern C++ types to work with C++11
Stars: ✭ 53 (+82.76%)
Mutual labels:  cpp20
MeetixOS
An hobby OS written in modern C++20 which aims to be Unix-like. Currently based on EvangelionNG, a GhostOS derived kernel
Stars: ✭ 179 (+517.24%)
Mutual labels:  cpp20
indifferent
Elixir Indifferent access on maps/lists/tuples with custom key transforms.
Stars: ✭ 20 (-31.03%)
Mutual labels:  parameters
SimpleConfig
No description or website provided.
Stars: ✭ 22 (-24.14%)
Mutual labels:  options
valkyrie
🔮 A UNIX-like toy kernel built from scratch (for AArch64) with preemptive multi-threading, VM, CoW fork(), buddy, slob, VFS, FAT32.
Stars: ✭ 57 (+96.55%)
Mutual labels:  cpp20
cleye
👁‍🗨 cleye — The intuitive & typed CLI development tool for Node.js
Stars: ✭ 235 (+710.34%)
Mutual labels:  parameters
zab
C++20 liburing backed coroutine executor and event loop framework.
Stars: ✭ 54 (+86.21%)
Mutual labels:  cpp20
Optino
Fully collateralised vanilla and bounded (capped call and floored put) crypto options
Stars: ✭ 16 (-44.83%)
Mutual labels:  options
focus-options-polyfill
JavaScript polyfill for the WHATWG spec of focusOptions, that enables a set of options to be passed to the focus method
Stars: ✭ 46 (+58.62%)
Mutual labels:  options
command-line-commands
Add a git-like command interface to your app.
Stars: ✭ 40 (+37.93%)
Mutual labels:  command-line-parser
USmallFlat
Ubpa small flat containers based on C++20
Stars: ✭ 20 (-31.03%)
Mutual labels:  cpp20

opzioni

opzioni is a command line arguments parser library for C++.

Goals

The goals of this library, in order of importance, are:

  1. Be as simple and enjoyable as possible.

    This mainly targets the user of the library, but also includes the user of the command line tool built with it.

  2. constexpr-all-the-things.

    Most of the time, all the information needed to build a command line interface is available at compile-time, so we should take advantage of that.

  3. If it compiles, it works.

    That's utopic, but that's what is being strived for. It's also very closely related to the previous goal. We should be able to detect most errors at compile-time and provide decent diagnostics.

  4. Try not to repeat yourself.

    When specifying a CLI, if some information was already given to the library, that same information should not be needed again. For example, if the type of an argument was already specified, the user should not be asked to tell the type again. Unfortunately that is very hard, so some places still require duplicate information.

  5. Be bleeding-edge.

    This library requires C++20. That limits a lot its potential users, but also allows for the use of the new and powerful features of C++. It also helps to accomplish the previous goals.

Disclaimer

  • This is a personal project with no promise of maintainability for the time being.

    I started it to learn more about C++ and its new features.

  • Although it is not in early development, since I'm working on it for months and iterated over it many times, it is not stable or production-ready.

  • There are many unit tests missing.

  • I frequently changed the interface of the library and I'm not afraid of changing it radically again if I think it would improve the UX.

    Another example is the names of the namespaces and what is in them.

  • There is a lot of polish and optimization work to do.

  • There is a whole documentation to write.

Sneak peek

The code below is a fully working example, taken from examples/hello.cpp, only reformatted and with quotes changed to angle brackets in the #include. Feel free to take a look at the other, more complex, examples in the same directory.

#include <iostream>
#include <string_view>

#include <opzioni.hpp>

int main(int argc, char const *argv[]) {
  using namespace opzioni;

  constexpr auto hello =
    Program("hello")
      .version("0.1")
      .intro("Greeting people since the dawn of computing")
      .add(Pos("name").help("Your name please, so I can greet you"))
      .add(Help())
      .add(Version());

  auto const args = hello(argc, argv);
  std::string_view const name = args["name"];
  std::cout << "Hello, " << name << "!\n";
}

That gives us:

  1. Automatic help with --help or -h

    $ ./build/examples/hello -h
    hello 0.1
    
    Greeting people since the dawn of computing
    
    Usage:
        hello <name> [--help] [--version]
    
    Positionals:
        name             Your name please, so I can greet you
    
    Options & Flags:
        -h, --help       Display this information
        -V, --version    Display the software version
    
  2. Automatic version with --version or -V

    $ ./build/examples/hello -V
    hello 0.1
    
  3. Automatic error handling

    $ ./build/examples/hello Gabriel Galli
    Unexpected positional argument `Galli`. This program expects 1 positional arguments
    
    Usage:
        hello <name> [--help] [--version]
    
  4. And finally:

    $ ./build/examples/hello "Gabriel Galli"
    Hello, Gabriel Galli!
    

Getting started

opzioni is not published anywhere yet. Meanwhile, it is kinda straightforward to build it locally, since just a simple conda environment is enough to bootstrap a development environment. The build system is the awesome Meson.

  1. Download and install conda if you haven't already. Just grab a suitable installer from here and run it. There's also an install guide here.

  2. Clone this repository:

    git clone https://github.com/ggabriel96/opzioni.git
  3. Create the conda environment:

    conda env create -f environment.yml
  4. Activate the newly created conda environment:

    conda activate opzioni
  5. Build it!

    make

Note that the Makefile is just a shortcut to the actual commands. Feel free to inspect it and not use it.

License

opzioni's license is the Boost Software License (BSL) 1.0.

This means you are free to use this library as you wish and see fit.

It is only needed to provide a copy of the license if the source is also being distributed.

In other words, there is no need to bundle opzioni's license with your binary.

Acknowledgements

Thank you to JetBrains for supporting this project by providing free access to its products as part of the Open Source Licenses program.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].