Skip to content

Commit

Permalink
version example
Browse files Browse the repository at this point in the history
  • Loading branch information
sisakat committed Apr 16, 2022
1 parent dc0f838 commit 70fdbcb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ A lightweight header only command line argument parsing library. Just download [

## Example
```cpp
#include "include/clapp.hpp"
#include "../include/clapp.hpp"
#include <iostream>

int main(int argc, char* argv[])
Expand All @@ -14,6 +14,13 @@ int main(int argc, char* argv[])
.description("Some really useful cli program.")
.addHelp();

parser.option("-v", "--version")
.flag()
.overruling()
.callback([](auto val) {
std::cout << "1.0" << std::endl;
});

std::string config;
parser.option<std::string>("-c", "--cfg")
.required()
Expand Down Expand Up @@ -45,9 +52,11 @@ int main(int argc, char* argv[])
Sample Application 1.0.0
Some really useful cli program.

./basic [-h] -c <json config file> [-s] [-f]
./basic [-h] [-v] -c <json config file> [-s]
[-f]
-h --help
Print this help message.
-v --version
-c --cfg <json config file>
Sets the config file.
-s
Expand All @@ -61,4 +70,9 @@ Some really useful cli program.
Config file: config.json
Silent mode set: 0
Flag set: 1
```
```
> ./basic -v
1.0
```
7 changes: 7 additions & 0 deletions examples/basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ int main(int argc, char* argv[])
.description("Some really useful cli program.")
.addHelp();

parser.option("-v", "--version")
.flag()
.overruling()
.callback([](auto val) {
std::cout << "1.0" << std::endl;
});

std::string config;
parser.option<std::string>("-c", "--cfg")
.required()
Expand Down

0 comments on commit 70fdbcb

Please sign in to comment.