Skip to content

Commit

Permalink
v0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse committed Dec 5, 2019
1 parent 9da44e4 commit 1327754
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 67 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
cmake_policy(VERSION 3.2)

set(ARGPARSE_VERSION "0.0.2")
set(ARGPARSE_VERSION "0.1.0")
project(argparse VERSION ${ARGPARSE_VERSION} LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 11)
Expand Down
119 changes: 53 additions & 66 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,43 @@
# argparse
[![Build Status](https://travis-ci.org/jamolnng/argparse.svg?branch=master)](https://travis-ci.org/jamolnng/argparse)

A simple header only command line argument parser

## Usage:
### Simple example
|Master|Develop|
|:-:|:-:|
|[![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)|

## Table of Contents
- [Building With Git and CMake](#Building-With-Git-and-CMake)
* [Make](#build-make)
* [VSCode and CMake Tools](#build-vscode)
* [Visual Studio](#build-vsc)
- [Usage](#Usage)
- [Running Tests](#Running-Tests)
* [Make](#test-make)
* [VSCode and CMake Tools](#test-vscode)
* [Visual Studio](#test-vsc)
- [Contributing](#Contributing)
- [License](#License)

## Building With Git and CMake
[Git](https://git-scm.com) and [CMake](https://cmake.org/)
### <a name="build-make"></a>Make
[Make](https://www.gnu.org/software/make/)
```bash
git clone https://github.com/jamolnng/argparse.git
cd argparse
mkdir build && cd build
cmake ..
make
```
### <a name="build-vscode"></a>VSCode and CMake Tools
[VSCode](https://code.visualstudio.com/) and [CMake Tools extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools)

TODO
### <a name="build-vsc"></a>Visual Studio
[Visual Studio Community](https://visualstudio.microsoft.com/vs/community/)

TODO
## Usage
```cpp
#include "argparse.h"

Expand Down Expand Up @@ -32,75 +65,29 @@ int main(int argc, char* argv[]) {
}
```
Example output:
```
```bash
> program -v 2
an even more verbose string
a verbose string
some verbosity
> program --verbose
some verbosity
```
### Full example
```cpp
#include "argparse.h"
#include <iostream>
#include <iterator>
int main(int argc, char* argv[]) {
// run as: [program name] "0 -c" abc -a 1 -sdfl --flag -v 1 2.7 3 4 9 8.12 87
// [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
ArgumentParser parser("Argument parser example");
parser.add_argument("-a", "an integer");
parser.add_argument("-s", "an combined flag", true);
parser.add_argument("-d", "an combined flag", true);
parser.add_argument("-f", "an combined flag", true);
parser.add_argument("--flag", "a flag");
parser.add_argument("-v", "a vector", true);
parser.add_argument("-l", "--long", "a long argument", false);
parser.add_argument("--files", "input files", false);
try {
parser.parse(argc, argv);
} catch (const ArgumentParser::ArgumentNotFound& ex) {
std::cout << ex.what() << std::endl;
return 0;
}
if (parser.is_help()) return 0;
std::cout << "a: " << parser.get<int>("a") << std::endl;
std::cout << "flag: " << std::boolalpha << parser.get<bool>("flag")
<< std::endl;
std::cout << "d: " << std::boolalpha << parser.get<bool>("d") << std::endl;
std::cout << "long flag: " << std::boolalpha << parser.get<bool>("l")
<< std::endl;
auto v = parser.getv<double>("v");
std::cout << "v: ";
std::copy(v.begin(), v.end(), std::ostream_iterator<double>(std::cout, " "));
double sum;
for (auto& d : v) sum += d;
std::cout << " sum: " << sum << std::endl;
auto f = parser.getv<std::string>("files");
std::cout << "files: ";
std::copy(f.begin(), f.end(),
std::ostream_iterator<std::string>(std::cout, " | "));
std::cout << std::endl;
f = parser.getv<std::string>("");
std::cout << "free args: ";
std::copy(f.begin(), f.end(),
std::ostream_iterator<std::string>(std::cout, " "));
std::cout << std::endl;
return 0;
}
## Running Tests
### <a name="test-make"></a>Make
```bash
make test
```
###
### <a name="test-vscode"></a>VSCode and CMake Tools
TODO
### <a name="test-vsc"></a>Visual Studio
TODO

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

### Example and Tests with CMake
```
mkdir build && cd build
cmake ..
make
```
Please make sure to update tests as appropriate.

## License
[GNU General Public License v3.0](https://github.com/jamolnng/argparse/blob/master/LICENSE)

0 comments on commit 1327754

Please sign in to comment.