Skip to content

Commit 1327754

Browse files
author
Jesse
committed
v0.1.0
1 parent 9da44e4 commit 1327754

File tree

2 files changed

+54
-67
lines changed

2 files changed

+54
-67
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
22
cmake_policy(VERSION 3.2)
33

4-
set(ARGPARSE_VERSION "0.0.2")
4+
set(ARGPARSE_VERSION "0.1.0")
55
project(argparse VERSION ${ARGPARSE_VERSION} LANGUAGES CXX)
66

77
set(CMAKE_CXX_STANDARD 11)

README.md

Lines changed: 53 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,43 @@
11
# argparse
2-
[![Build Status](https://travis-ci.org/jamolnng/argparse.svg?branch=master)](https://travis-ci.org/jamolnng/argparse)
3-
42
A simple header only command line argument parser
53

6-
## Usage:
7-
### Simple example
4+
|Master|Develop|
5+
|:-:|:-:|
6+
|[![Build Status](https://travis-ci.com/jamolnng/argparse.svg?branch=master)](https://travis-ci.com/jamolnng/argparse)|[![Build Status](https://travis-ci.com/jamolnng/argparse.svg?branch=develop)](https://travis-ci.com/jamolnng/argparse)|
7+
8+
## Table of Contents
9+
- [Building With Git and CMake](#Building-With-Git-and-CMake)
10+
* [Make](#build-make)
11+
* [VSCode and CMake Tools](#build-vscode)
12+
* [Visual Studio](#build-vsc)
13+
- [Usage](#Usage)
14+
- [Running Tests](#Running-Tests)
15+
* [Make](#test-make)
16+
* [VSCode and CMake Tools](#test-vscode)
17+
* [Visual Studio](#test-vsc)
18+
- [Contributing](#Contributing)
19+
- [License](#License)
20+
21+
## Building With Git and CMake
22+
[Git](https://git-scm.com) and [CMake](https://cmake.org/)
23+
### <a name="build-make"></a>Make
24+
[Make](https://www.gnu.org/software/make/)
25+
```bash
26+
git clone https://github.com/jamolnng/argparse.git
27+
cd argparse
28+
mkdir build && cd build
29+
cmake ..
30+
make
31+
```
32+
### <a name="build-vscode"></a>VSCode and CMake Tools
33+
[VSCode](https://code.visualstudio.com/) and [CMake Tools extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools)
34+
35+
TODO
36+
### <a name="build-vsc"></a>Visual Studio
37+
[Visual Studio Community](https://visualstudio.microsoft.com/vs/community/)
38+
39+
TODO
40+
## Usage
841
```cpp
942
#include "argparse.h"
1043

@@ -32,75 +65,29 @@ int main(int argc, char* argv[]) {
3265
}
3366
```
3467
Example output:
35-
```
68+
```bash
3669
> program -v 2
3770
an even more verbose string
3871
a verbose string
3972
some verbosity
4073
> program --verbose
4174
some verbosity
4275
```
43-
44-
### Full example
45-
46-
```cpp
47-
#include "argparse.h"
48-
49-
#include <iostream>
50-
#include <iterator>
51-
52-
int main(int argc, char* argv[]) {
53-
// run as: [program name] "0 -c" abc -a 1 -sdfl --flag -v 1 2.7 3 4 9 8.12 87
54-
// [program name] -sdfv 1 -o "C:\Users\User Name\Directory - Name\file.dat" "C:\Users\User Name 2\Directory 2 - Name 2\file2.dat" C:/tmp/tmp.txt
55-
ArgumentParser parser("Argument parser example");
56-
parser.add_argument("-a", "an integer");
57-
parser.add_argument("-s", "an combined flag", true);
58-
parser.add_argument("-d", "an combined flag", true);
59-
parser.add_argument("-f", "an combined flag", true);
60-
parser.add_argument("--flag", "a flag");
61-
parser.add_argument("-v", "a vector", true);
62-
parser.add_argument("-l", "--long", "a long argument", false);
63-
parser.add_argument("--files", "input files", false);
64-
try {
65-
parser.parse(argc, argv);
66-
} catch (const ArgumentParser::ArgumentNotFound& ex) {
67-
std::cout << ex.what() << std::endl;
68-
return 0;
69-
}
70-
if (parser.is_help()) return 0;
71-
std::cout << "a: " << parser.get<int>("a") << std::endl;
72-
std::cout << "flag: " << std::boolalpha << parser.get<bool>("flag")
73-
<< std::endl;
74-
std::cout << "d: " << std::boolalpha << parser.get<bool>("d") << std::endl;
75-
std::cout << "long flag: " << std::boolalpha << parser.get<bool>("l")
76-
<< std::endl;
77-
auto v = parser.getv<double>("v");
78-
std::cout << "v: ";
79-
std::copy(v.begin(), v.end(), std::ostream_iterator<double>(std::cout, " "));
80-
double sum;
81-
for (auto& d : v) sum += d;
82-
std::cout << " sum: " << sum << std::endl;
83-
auto f = parser.getv<std::string>("files");
84-
std::cout << "files: ";
85-
std::copy(f.begin(), f.end(),
86-
std::ostream_iterator<std::string>(std::cout, " | "));
87-
std::cout << std::endl;
88-
f = parser.getv<std::string>("");
89-
std::cout << "free args: ";
90-
std::copy(f.begin(), f.end(),
91-
std::ostream_iterator<std::string>(std::cout, " "));
92-
std::cout << std::endl;
93-
return 0;
94-
}
76+
## Running Tests
77+
### <a name="test-make"></a>Make
78+
```bash
79+
make test
9580
```
81+
###
82+
### <a name="test-vscode"></a>VSCode and CMake Tools
83+
TODO
84+
### <a name="test-vsc"></a>Visual Studio
85+
TODO
9686

97-
## Building:
98-
### In your own project
99-
Just add `argparse.h` to your include path.
87+
## Contributing
88+
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
10089

101-
### Example and Tests with CMake
102-
```
103-
mkdir build && cd build
104-
cmake ..
105-
make
106-
```
90+
Please make sure to update tests as appropriate.
91+
92+
## License
93+
[GNU General Public License v3.0](https://github.com/jamolnng/argparse/blob/master/LICENSE)

0 commit comments

Comments
 (0)