Skip to content

Latest commit

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

flags

A very simple command line arguments parser with single header file.

C++ 17 REQUIRED.

Quick Start

Example

#include<iostream>
#include"flags.hpp"structexample_option
{
std::string ip{};
uint16_t port{ 6014 };
bool keep_alive{ false };
};
intmain(int argc, char** argv)
{
auto opts = flags<example_option>("flags example v1.0", {
{ "-ip", "ip address, like 192.168.1.14", &example_option::ip },
{ "-port", "port, default is 6014", &example_option::port },
{ "-keepalive", "keep alive, default is false", &example_option::keep_alive },
})(argc, argv);
std::cout << "options: " << ".ip=" << opts.ip << ", " << ".port=" << opts.port << ", " << ".keep_alive=" << std::boolalpha << opts.keep_alive << std::endl;
}

Usage

:: help> example.exe --help
flags example v1.0
--help show this help message
--version show app version
-ip ip address, like 192.168.1.14
-port port, default is 6014
-keepalive keep alive, default is false :: version> example.exe --version
flags example v1.0
:: use => example.exe -ip=192.168.1.14
options: .ip=192.168.1.14, .port=6014, .keep_alive=false
:: use space> example.exe -ip 192.168.1.14
options: .ip=192.168.1.14, .port=6014, .keep_alive=false 

License

The project is available under the MIT license.

About

A very simple command line arguments parser with single header file.

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages