diff --git a/CMakeLists.txt b/CMakeLists.txt index 5057b2c..8b0d948 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/README.md b/README.md index 9969662..0153deb 100644 --- a/README.md +++ b/README.md @@ -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/) +### 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 +``` +### VSCode and CMake Tools +[VSCode](https://code.visualstudio.com/) and [CMake Tools extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools) + +TODO +### Visual Studio +[Visual Studio Community](https://visualstudio.microsoft.com/vs/community/) + +TODO +## Usage ```cpp #include "argparse.h" @@ -32,7 +65,7 @@ int main(int argc, char* argv[]) { } ``` Example output: -``` +```bash > program -v 2 an even more verbose string a verbose string @@ -40,67 +73,21 @@ some verbosity > program --verbose some verbosity ``` - -### Full example - -```cpp -#include "argparse.h" - -#include -#include - -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("a") << std::endl; - std::cout << "flag: " << std::boolalpha << parser.get("flag") - << std::endl; - std::cout << "d: " << std::boolalpha << parser.get("d") << std::endl; - std::cout << "long flag: " << std::boolalpha << parser.get("l") - << std::endl; - auto v = parser.getv("v"); - std::cout << "v: "; - std::copy(v.begin(), v.end(), std::ostream_iterator(std::cout, " ")); - double sum; - for (auto& d : v) sum += d; - std::cout << " sum: " << sum << std::endl; - auto f = parser.getv("files"); - std::cout << "files: "; - std::copy(f.begin(), f.end(), - std::ostream_iterator(std::cout, " | ")); - std::cout << std::endl; - f = parser.getv(""); - std::cout << "free args: "; - std::copy(f.begin(), f.end(), - std::ostream_iterator(std::cout, " ")); - std::cout << std::endl; - return 0; -} +## Running Tests +### Make +```bash +make test ``` +### +### VSCode and CMake Tools +TODO +### 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) \ No newline at end of file