77 | This library is written in portable C++11.
78 | The header file exports an args::ArgParser class which provides the public interface to the library.
79 |
87 | Initialize an ArgParser instance. Supplying help text activates an automatic --help flag; supplying a version string activates an automatic --version flag. (Automatic -h and -v shortcuts are also activated unless registered by other options.)
88 |
89 |
90 |
91 |
92 |
93 | void .parse(int argc, char **argv)
94 |
95 |
96 |
97 | Parse the application's command line arguments.
98 | Arguments are assumed to be argc and argv as supplied to main().
99 | Parsed option values can be retrieved from the parser instance itself.
100 |
101 |
102 |
103 |
104 |
105 | Flags and Options
106 |
107 |
108 |
109 |
110 | void .flag(string name)
111 |
112 |
113 |
114 | Registers a new flag.
115 | The name parameter accepts an unlimited number of space-separated aliases and single-character shortcuts.
116 |
125 | Registers a new option.
126 | The name parameter accepts an unlimited number of space-separated aliases and single-character shortcuts.
127 | A fallback value can be specified which will be used if the option is not found.
128 |
129 |
130 |
131 |
132 |
133 | Retrieving Values
134 |
135 |
136 |
137 |
138 | bool .found(string name)
139 |
140 |
141 |
142 | Returns true if the specified flag or option was found.
143 |
144 |
145 |
146 |
147 |
148 | int .count(string name)
149 |
150 |
151 |
152 | Returns the number of times the specified flag or option was found.
153 |
154 |
155 |
156 |
157 |
158 | string .value(string name)
159 |
160 |
161 |
162 | Returns the value of the specified option. Returns the fallback value if the option was not found.
163 |
164 |
165 |
166 |
167 |
168 | vector<string> .values(string name)
169 |
170 |
171 |
172 | Returns the specified option's list of values.
173 |
202 | Registers a new command.
203 | The name parameter accepts an unlimited number of space-separated aliases.
204 | Returns a reference to the command's ArgParser instance — you can register the command's flags and options on this parser using the standard methods listed above.
205 | If the command is found the callback function will be called with the command's name and ArgParser instance.
206 |
207 |
208 |
209 |
210 |
211 | bool .commandFound()
212 |
213 |
214 |
215 | Returns true if a command was found.
216 |
217 |
218 |
219 |
220 |
221 | string .commandName()
222 |
223 |
224 |
225 | Returns the command name if a command was found.
226 |
227 |
228 |
229 |
230 |
231 | ArgParser& .commandParser()
232 |
233 |
234 |
235 | Returns the command's parser instance if a command was found.
236 |
tags unless they have a 'no-copy' class.
2 | document.addEventListener("DOMContentLoaded", function() {
3 | if (!navigator.clipboard) {
4 | return;
5 | }
6 |
7 | document.querySelectorAll("pre").forEach(node => {
8 | if (node.classList.contains("no-copy")) {
9 | return;
10 | }
11 |
12 | var wrapper = document.createElement('div');
13 | wrapper.classList.add("pre-copy-wrapper");
14 | node.parentNode.insertBefore(wrapper, node);
15 | wrapper.appendChild(node);
16 |
17 | let copyBtn = document.createElement("button");
18 | copyBtn.innerText = "[COPY]";
19 | wrapper.appendChild(copyBtn);
20 |
21 | copyBtn.addEventListener("click", async () => {
22 | let text = node.innerText;
23 | await navigator.clipboard.writeText(text);
24 | copyBtn.innerText = "[COPIED]";
25 | setTimeout(() => copyBtn.innerText = "[COPY]", 1000);
26 | })
27 | })
28 | });
29 |
--------------------------------------------------------------------------------
/docs/out/assets/fonts.css:
--------------------------------------------------------------------------------
1 | /**
2 | * -------------------------------------------------------------------------
3 | * Google fonts served locally.
4 | * -------------------------------------------------------------------------
5 | */
6 |
7 | @font-face {
8 | font-family: 'Crimson Text';
9 | font-style: normal;
10 | font-weight: 400;
11 | src: local('Crimson Text Regular'),
12 | local('CrimsonText-Regular'),
13 | url(fonts/CrimsonText-Regular.woff2) format('woff2'),
14 | url(fonts/CrimsonText-Regular.ttf) format('truetype');
15 | }
16 |
17 | @font-face {
18 | font-family: 'Crimson Text';
19 | font-style: italic;
20 | font-weight: 400;
21 | src: local('Crimson Text Italic'),
22 | local('CrimsonText-Italic'),
23 | url(fonts/CrimsonText-Italic.woff2) format('woff2'),
24 | url(fonts/CrimsonText-Italic.ttf) format('truetype');
25 | }
26 |
27 | @font-face {
28 | font-family: 'Crimson Text';
29 | font-style: normal;
30 | font-weight: 700;
31 | src: local('Crimson Text Bold'),
32 | local('CrimsonText-Bold'),
33 | url(fonts/CrimsonText-Bold.woff2) format('woff2'),
34 | url(fonts/CrimsonText-Bold.ttf) format('truetype');
35 | }
36 |
37 | /*
38 | The fonts below are packaged with the theme and can be uncommented
39 | if needed.
40 | */
41 |
42 | /*
43 | @font-face {
44 | font-family: 'Crimson Text';
45 | font-style: italic;
46 | font-weight: 700;
47 | src: local('Crimson Text Bold Italic'),
48 | local('CrimsonText-BoldItalic'),
49 | url(fonts/CrimsonText-BoldItalic.woff2) format('woff2'),
50 | url(fonts/CrimsonText-BoldItalic.ttf) format('truetype');
51 | }
52 |
53 | @font-face {
54 | font-family: 'Crimson Text';
55 | font-style: normal;
56 | font-weight: 600;
57 | src: local('Crimson Text SemiBold'),
58 | local('CrimsonText-SemiBold'),
59 | url(fonts/CrimsonText-SemiBold.woff2) format('woff2'),
60 | url(fonts/CrimsonText-SemiBold.ttf) format('truetype');
61 | }
62 |
63 | @font-face {
64 | font-family: 'Crimson Text';
65 | font-style: italic;
66 | font-weight: 600;
67 | src: local('Crimson Text SemiBold Italic'),
68 | local('CrimsonText-SemiBoldItalic'),
69 | url(fonts/CrimsonText-SemiBoldItalic.woff2) format('woff2'),
70 | url(fonts/CrimsonText-SemiBoldItalic.ttf) format('truetype');
71 | }
72 | */
73 |
--------------------------------------------------------------------------------
/docs/out/assets/fonts/CrimsonText-Bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dmulholl/argspp/b3b9423cfb40e2b9baa2953c1fe91027d2c05cc4/docs/out/assets/fonts/CrimsonText-Bold.ttf
--------------------------------------------------------------------------------
/docs/out/assets/fonts/CrimsonText-Bold.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dmulholl/argspp/b3b9423cfb40e2b9baa2953c1fe91027d2c05cc4/docs/out/assets/fonts/CrimsonText-Bold.woff2
--------------------------------------------------------------------------------
/docs/out/assets/fonts/CrimsonText-BoldItalic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dmulholl/argspp/b3b9423cfb40e2b9baa2953c1fe91027d2c05cc4/docs/out/assets/fonts/CrimsonText-BoldItalic.ttf
--------------------------------------------------------------------------------
/docs/out/assets/fonts/CrimsonText-BoldItalic.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dmulholl/argspp/b3b9423cfb40e2b9baa2953c1fe91027d2c05cc4/docs/out/assets/fonts/CrimsonText-BoldItalic.woff2
--------------------------------------------------------------------------------
/docs/out/assets/fonts/CrimsonText-Italic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dmulholl/argspp/b3b9423cfb40e2b9baa2953c1fe91027d2c05cc4/docs/out/assets/fonts/CrimsonText-Italic.ttf
--------------------------------------------------------------------------------
/docs/out/assets/fonts/CrimsonText-Italic.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dmulholl/argspp/b3b9423cfb40e2b9baa2953c1fe91027d2c05cc4/docs/out/assets/fonts/CrimsonText-Italic.woff2
--------------------------------------------------------------------------------
/docs/out/assets/fonts/CrimsonText-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dmulholl/argspp/b3b9423cfb40e2b9baa2953c1fe91027d2c05cc4/docs/out/assets/fonts/CrimsonText-Regular.ttf
--------------------------------------------------------------------------------
/docs/out/assets/fonts/CrimsonText-Regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dmulholl/argspp/b3b9423cfb40e2b9baa2953c1fe91027d2c05cc4/docs/out/assets/fonts/CrimsonText-Regular.woff2
--------------------------------------------------------------------------------
/docs/out/assets/fonts/CrimsonText-SemiBold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dmulholl/argspp/b3b9423cfb40e2b9baa2953c1fe91027d2c05cc4/docs/out/assets/fonts/CrimsonText-SemiBold.ttf
--------------------------------------------------------------------------------
/docs/out/assets/fonts/CrimsonText-SemiBold.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dmulholl/argspp/b3b9423cfb40e2b9baa2953c1fe91027d2c05cc4/docs/out/assets/fonts/CrimsonText-SemiBold.woff2
--------------------------------------------------------------------------------
/docs/out/assets/fonts/CrimsonText-SemiBoldItalic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dmulholl/argspp/b3b9423cfb40e2b9baa2953c1fe91027d2c05cc4/docs/out/assets/fonts/CrimsonText-SemiBoldItalic.ttf
--------------------------------------------------------------------------------
/docs/out/assets/fonts/CrimsonText-SemiBoldItalic.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dmulholl/argspp/b3b9423cfb40e2b9baa2953c1fe91027d2c05cc4/docs/out/assets/fonts/CrimsonText-SemiBoldItalic.woff2
--------------------------------------------------------------------------------
/docs/out/assets/fonts/OFL.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2010, Sebastian Kosch (sebastian@aldusleaf.org),
2 | with Reserved Font Name "Crimson" and "Crimson Text".
3 | This Font Software is licensed under the SIL Open Font License, Version 1.1.
4 | This license is copied below, and is also available with a FAQ at:
5 | http://scripts.sil.org/OFL
6 |
7 |
8 | -----------------------------------------------------------
9 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10 | -----------------------------------------------------------
11 |
12 | PREAMBLE
13 | The goals of the Open Font License (OFL) are to stimulate worldwide
14 | development of collaborative font projects, to support the font creation
15 | efforts of academic and linguistic communities, and to provide a free and
16 | open framework in which fonts may be shared and improved in partnership
17 | with others.
18 |
19 | The OFL allows the licensed fonts to be used, studied, modified and
20 | redistributed freely as long as they are not sold by themselves. The
21 | fonts, including any derivative works, can be bundled, embedded,
22 | redistributed and/or sold with any software provided that any reserved
23 | names are not used by derivative works. The fonts and derivatives,
24 | however, cannot be released under any other type of license. The
25 | requirement for fonts to remain under this license does not apply
26 | to any document created using the fonts or their derivatives.
27 |
28 | DEFINITIONS
29 | "Font Software" refers to the set of files released by the Copyright
30 | Holder(s) under this license and clearly marked as such. This may
31 | include source files, build scripts and documentation.
32 |
33 | "Reserved Font Name" refers to any names specified as such after the
34 | copyright statement(s).
35 |
36 | "Original Version" refers to the collection of Font Software components as
37 | distributed by the Copyright Holder(s).
38 |
39 | "Modified Version" refers to any derivative made by adding to, deleting,
40 | or substituting -- in part or in whole -- any of the components of the
41 | Original Version, by changing formats or by porting the Font Software to a
42 | new environment.
43 |
44 | "Author" refers to any designer, engineer, programmer, technical
45 | writer or other person who contributed to the Font Software.
46 |
47 | PERMISSION & CONDITIONS
48 | Permission is hereby granted, free of charge, to any person obtaining
49 | a copy of the Font Software, to use, study, copy, merge, embed, modify,
50 | redistribute, and sell modified and unmodified copies of the Font
51 | Software, subject to the following conditions:
52 |
53 | 1) Neither the Font Software nor any of its individual components,
54 | in Original or Modified Versions, may be sold by itself.
55 |
56 | 2) Original or Modified Versions of the Font Software may be bundled,
57 | redistributed and/or sold with any software, provided that each copy
58 | contains the above copyright notice and this license. These can be
59 | included either as stand-alone text files, human-readable headers or
60 | in the appropriate machine-readable metadata fields within text or
61 | binary files as long as those fields can be easily viewed by the user.
62 |
63 | 3) No Modified Version of the Font Software may use the Reserved Font
64 | Name(s) unless explicit written permission is granted by the corresponding
65 | Copyright Holder. This restriction only applies to the primary font name as
66 | presented to the users.
67 |
68 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69 | Software shall not be used to promote, endorse or advertise any
70 | Modified Version, except to acknowledge the contribution(s) of the
71 | Copyright Holder(s) and the Author(s) or with their explicit written
72 | permission.
73 |
74 | 5) The Font Software, modified or unmodified, in part or in whole,
75 | must be distributed entirely under this license, and must not be
76 | distributed under any other license. The requirement for fonts to
77 | remain under this license does not apply to any document created
78 | using the Font Software.
79 |
80 | TERMINATION
81 | This license becomes null and void if any of the above conditions are
82 | not met.
83 |
84 | DISCLAIMER
85 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93 | OTHER DEALINGS IN THE FONT SOFTWARE.
94 |
--------------------------------------------------------------------------------
/docs/out/assets/graphite.css:
--------------------------------------------------------------------------------
1 | /**
2 | * -------------------------------------------------------------------------
3 | * Micro Reset
4 | * -------------------------------------------------------------------------
5 | */
6 |
7 | *, *:before, *:after {
8 | box-sizing: inherit;
9 | }
10 |
11 | html {
12 | box-sizing: border-box;
13 | font-size: 100%;
14 | -webkit-text-size-adjust: none;
15 | text-size-adjust: none;
16 | }
17 |
18 | body {
19 | margin: 0;
20 | padding: 0;
21 | }
22 |
23 | form, fieldset, legend {
24 | margin: 0;
25 | padding: 0;
26 | }
27 |
28 | button, input, select, textarea, label {
29 | margin: 0;
30 | padding: 0;
31 | font-family: inherit;
32 | font-size: inherit;
33 | }
34 |
35 | img {
36 | border: 0;
37 | max-width: 100%;
38 | }
39 |
40 | /**
41 | * -------------------------------------------------------------------------
42 | * Typography
43 | * -------------------------------------------------------------------------
44 | */
45 |
46 | body {
47 | font-size: 17px;
48 | color: black;
49 | font-family: 'Crimson Text', Georgia, serif;
50 | line-height: 1.75;
51 | }
52 |
53 | h1 {
54 | padding: 0;
55 | margin: 80px 0 30px;
56 | line-height: 1.25;
57 | text-align: center;
58 | font-size: 32px;
59 | font-weight: normal;
60 | }
61 |
62 | h2 {
63 | padding: 0;
64 | margin: 80px 0 30px;
65 | line-height: 1.25;
66 | text-align: center;
67 | font-size: 22px;
68 | font-weight: bold;
69 | }
70 |
71 | h2.underline {
72 | padding: 0;
73 | margin: 80px 0 35px;
74 | line-height: 1.25;
75 | text-align: left;
76 | font-size: 22px;
77 | font-weight: bold;
78 | padding-bottom: 5px;
79 | border-bottom: 1px solid #ccc;
80 | }
81 |
82 | h3, h4, h5, h6 {
83 | padding: 0;
84 | margin: 80px 0 30px;
85 | line-height: 1.25;
86 | text-align: left;
87 | font-size: 19px;
88 | font-weight: bold;
89 | }
90 |
91 | p {
92 | margin: 25px 0;
93 | padding: 0;
94 | overflow-wrap: break-word;
95 | }
96 |
97 | blockquote {
98 | margin: 40px 0px;
99 | padding: 0 20px;
100 | border-left: 3px solid #ddd;
101 | font-style: italic;
102 | }
103 |
104 | .blockquote-caption {
105 | margin: -10px 20px 40px;
106 | text-align: right;
107 | }
108 |
109 | abbr[title] {
110 | border-bottom: 1px dotted;
111 | cursor: help;
112 | }
113 |
114 | sup, sub {
115 | font-size: 75%;
116 | line-height: 0;
117 | position: relative;
118 | vertical-align: baseline;
119 | }
120 |
121 | sup {
122 | bottom: 1.5ex;
123 | padding: 0 0.5ex;
124 | }
125 |
126 | sub {
127 | top: .5ex;
128 | }
129 |
130 | /**
131 | * Code
132 | */
133 |
134 | pre, code {
135 | font-size: 13px;
136 | font-family: Courier, monospace;
137 | }
138 |
139 | code {
140 | margin: 0 2px;
141 | padding: 1px 5px;
142 | white-space: nowrap;
143 | border: 1px solid #e8e8e8;
144 | border-radius: 3px;
145 | background-color: #f8f8f8;
146 | }
147 |
148 | pre {
149 | margin: 40px 0;
150 | padding: 16px 20px;
151 | border-top: 1px dotted #bbb;
152 | border-bottom: 1px dotted #bbb;
153 | background-color: #f8f8f8;
154 | overflow: auto;
155 | line-height: 1.4;
156 | }
157 |
158 | /* Markdown renderers tend to wrap code blocks in
80 | An option can have an unlimited number of long-form aliases and single-character shortcuts: --option, -o.
81 |
82 |
83 | Option values can be separated by either a space, --opt 123, or an equals symbol, --opt=123. Either syntax can be used with shortcuts: -o 123, -o=123.
84 |
85 |
86 | Multiple shortcuts can be condensed into a single block, e.g. -abc foo bar. Trailing arguments are consumed in sequence as required by the options.
87 |
88 |
89 | Options are registered with default values which are used if the option is not found. If an option is found multiple times its value is the final value encountered.
90 |
91 |
92 | Multivalued Options
93 |
94 |
95 | Options can be treated as singular or multivalued as circumstances require. Each option maintains an internal list to which newly parsed values are appended; the (singular) value of the option is the final value in the list or the default value if the list is empty.
96 |
97 |
98 | For example, in the command below:
99 |
100 |
101 | $ myapp --foo abc --foo def
102 |
103 |
104 | the value of the option foo is "def" but the array ["abc", "def"] is also available for use if required.
105 |
106 |
107 | Flags
108 |
109 |
110 | Flags are valueless options — they're either present or absent, but take no arguments. Like options, flags can have an unlimited number of long-form aliases and single-character shortcuts: --flag, -f.
111 |
112 |
113 | Positional Arguments
114 |
115 |
116 | Options and flags can be preceded by, followed by, or interspaced with positional arguments which are assembled by the parser into an array of strings.
117 |
118 |
119 | The parser supports the standard -- switch for turning off option-parsing. All arguments following a -- will be treated as positional arguments, even if they begin with a single or double dash.
120 |
121 |
122 | Commands
123 |
124 |
125 | This library supports git-style command interfaces with arbitrarily-nested commands. Commands have builtin support for an automatic --help flag and an automatic help <cmd> command, i.e. the commands
126 |
127 |
128 | $ myapp <cmd> --help
129 |
130 |
131 | and
132 |
133 |
134 | $ myapp help <cmd>
135 |
136 |
137 | are functionally identical and will both print the help text registered with the command.
138 |
139 |
140 | Negative Numbers
141 |
142 |
143 | Some argument-parsing libraries struggle with negative numbers — for example, they will try to parse -3 as a flag or option named 3. This library always treats arguments beginning with a dash and a digit as positional arguments or option values, never as flag or option names.
144 |
A ridiculously simple argument-parsing library for C++.
27 |
28 |
29 |
Version 2.1.0
30 |
31 |
47 |
48 |
49 |
50 |
51 |
License
52 |
53 |
54 |
55 |
56 | This library is released under the Zero-Clause BSD licence (0BSD):
57 |
58 |
59 | Permission to use, copy, modify, and/or distribute this
60 | software for any purpose with or without fee is hereby
61 | granted.
62 |
63 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS
64 | ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
65 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
66 | EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
67 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
68 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
69 | WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
70 | TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
71 | USE OR PERFORMANCE OF THIS SOFTWARE.
72 |
A ridiculously simple argument-parsing library for C++.
27 |
28 |
29 |
Version 2.1.0
30 |
31 |
47 |
48 |
49 |
50 |
51 |
Quickstart Tutorial
52 |
53 |
54 |
55 |
56 | Imagine we're building a utility for joining MP3 files, something like mp3cat.
57 | We want the user to supply the file names as a list of command line arguments.
58 | We also want to support an --out/-o option so the user can specify an output filename and a --quiet/-q flag for turning down the program's verbosity.
59 |
60 |
61 | First we need to create an ArgParser instance:
62 |
71 | Supplying a helptext string for the parser activates an automatic --help/-h flag; similarly, supplying a version string activates an automatic --version/-v flag.
72 |
73 |
74 | Now we can register our options and flags:
75 |
81 | That's it, we're done specifying our interface. Now we can parse the program's command line arguments, passing in argc and argv as supplied to main():
82 |
83 |
84 | parser.parse(argc,argv);
85 |
86 |
87 | This will exit with a suitable error message for the user if anything goes wrong. Now we can check if the --quiet flag was found:
88 |