|
1 | 1 | # argparse
|
2 |
| -[](https://travis-ci.org/jamolnng/argparse) |
3 |
| - |
4 | 2 | A simple header only command line argument parser
|
5 | 3 |
|
6 |
| -## Usage: |
7 |
| -### Simple example |
| 4 | +|Master|Develop| |
| 5 | +|:-:|:-:| |
| 6 | +|[](https://travis-ci.com/jamolnng/argparse)|[](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 |
8 | 41 | ```cpp
|
9 | 42 | #include "argparse.h"
|
10 | 43 |
|
@@ -32,75 +65,29 @@ int main(int argc, char* argv[]) {
|
32 | 65 | }
|
33 | 66 | ```
|
34 | 67 | Example output:
|
35 |
| -``` |
| 68 | +```bash |
36 | 69 | > program -v 2
|
37 | 70 | an even more verbose string
|
38 | 71 | a verbose string
|
39 | 72 | some verbosity
|
40 | 73 | > program --verbose
|
41 | 74 | some verbosity
|
42 | 75 | ```
|
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 |
95 | 80 | ```
|
| 81 | +### |
| 82 | +### <a name="test-vscode"></a>VSCode and CMake Tools |
| 83 | +TODO |
| 84 | +### <a name="test-vsc"></a>Visual Studio |
| 85 | +TODO |
96 | 86 |
|
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. |
100 | 89 |
|
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