Commit Graph

103 Commits

Author SHA1 Message Date
Ashwin Rohit
2c55a2e423 Modify README.md to show printing errors to stderr instead of stdout 2021-10-31 12:29:19 -07:00
Sean Robinson
5cceb98e3c Update "Printing Help" documentation
Help output has changed format over time.  This updates the README
example to reflect current practice by running the example code
and copy-pasting its output.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2021-10-27 09:02:33 -07:00
Sean Robinson
ea1f7ef663 Allow removal of default arguments (i.e. --help and --version)
The help and version arguments are still included by default, but which
default arguments to include can be overridden at ArgumentParser creation.

argparse generally copies Python argparse behavior.  This includes a
default `--help`/`-h` argument to print a help message and exit.  Some
developers using argparse find the automatic exit to be undesirable.

The Python argparse has an opt-out parameter when constructing an
ArgumentParser.  Using `add_help=False` avoids adding a default `--help`
argument and allows the developer to implement a custom help.

This commit adds a similar opt-out to our C++ argparse, but keeps the
current behavior as the default.  The `--help`/`-h` and `--version`/`-v`
Arguments handle their own output and exit rather than specially treating
them in ArgumentParser::parse_args_internal.

Closes #119
Closes #138
Closes #139

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2021-10-27 09:02:33 -07:00
Sean Robinson
2b05334a3c Run Argumnet::action functor for zero-parameter arguments
Previously, only arguments with one or more parameters would run actions.
But, at times it can be useful to run an action when an argument does not
expect any parameters.

Closes #104

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2021-10-27 09:02:33 -07:00
Sean Robinson
58777d8c84 Replace spaces with underscores in example program names
These examples give a false impression that a space in the middle of the
application name is well handled.  While a space might be possible, it
must be escaped in shells, i.e. a common environment for a CLI argument
parser.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2021-10-27 09:02:33 -07:00
Sean Robinson
8772b37aab Update examples from exit() to std::exit()
argparse seems to use the "std::" qualifier for std namespace members,
continue that in the documentation.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2021-10-27 09:02:33 -07:00
Sean Robinson
38a4a1a755 Replace simple type-converting Argument.action with Argument.scan in README
To better show the built-in conversion to a primitive type, use .scan in
examples.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2021-08-24 09:25:49 -07:00
Sean Robinson
bcc1f5adea Add documentation for Argument.scan
IMHO, the .scan function and its supporting functions are beautiful
metaprogramming that needs to be more visible to argparse users.  As a
start, document the function, with simple examples.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2021-08-24 09:25:49 -07:00
Sean Robinson
3efd045ea9 Add ArgumentParser.is_used to discern user-supplied values from defaults
.present returns std::nullopt if the optional argument is not given by the
user -- as long as a .default_value is not defined.  With a .default_value,
.present cannot be used to determine if a value is user-provided or the
default.

.is_used fills that role and only returns true if the argument was passed
by the user.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2021-04-07 14:09:10 -07:00
Sean Robinson
54d3cda804 Add Argument.append method to allow repeated argument use
The default behavior with optional arguments is to allow only a single use
per invocation.  One alternative is to use .nargs, but this requires
previously knowing, and limiting, the quantity of values.  The .append
method removes the restriction on repeats for a single Argument.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2021-04-07 11:47:09 -07:00
Sean Robinson
a711f26045 Remove trailing spaces from README lines
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2021-04-06 12:07:53 -07:00
Pranav
176da54c9b
Update README.md 2020-05-17 11:09:00 -05:00
Pranav
06649254b3
Update README.md 2020-05-15 19:12:43 -05:00
Pranav Srinivas Kumar
33101e7972 Closes #73 2020-05-08 14:35:05 -05:00
Pranav
45664c4e9f
Update README.md 2020-01-02 20:58:10 -06:00
Pranav
e06890af97
Update README.md 2019-12-01 16:56:19 -06:00
Zhihao Yuan
e6c6c9b31c
Get arguments in optional<T> with .present<T>()
fixes: p-ranav/argparse#66
2019-12-01 02:14:13 -06:00
Zhihao Yuan
ea2f16d264
Upgrade and describe supported toolchains 2019-11-25 17:23:28 -06:00
Pranav
9cac1d0fed
Update README.md 2019-11-22 08:02:44 -06:00
Pranav Srinivas Kumar
da58b28ccb
Update README.md 2019-11-21 10:00:43 -06:00
Pranav Srinivas Kumar
c95835acf8
Update README.md 2019-11-21 08:37:47 -06:00
Pranav Srinivas Kumar
b42c6b7c7e
Update README.md 2019-11-21 08:37:04 -06:00
Pranav Srinivas Kumar
c803c32804
Update README.md 2019-11-21 08:29:34 -06:00
Zhihao Yuan
3f949fc3f1
Stop sharing argument values with parent parsers
See also: p-ranav/argparse#50
2019-11-16 14:33:00 -06:00
Zhihao Yuan
dc74051832
Deprecate print_help()
closes: p-ranav/argparse#40
2019-11-13 02:40:15 -06:00
Pranav Srinivas Kumar
79eba4e81f
Update README.md 2019-09-13 19:47:44 -05:00
Pranav Srinivas Kumar
61e9b644c0
Update README.md 2019-09-10 10:15:15 -05:00
Pranav Srinivas Kumar
db9f81e19a
Update README.md 2019-08-27 10:28:40 -05:00
Pranav Srinivas Kumar
8df0a878ac Merge branch 'master' of github.com:p-ranav/argparse 2019-08-17 16:57:15 -05:00
Pranav Srinivas Kumar
e40d9d5513 Closes #35 2019-08-17 16:57:00 -05:00
Pranav Srinivas Kumar
a2bd798920
Update README.md 2019-06-16 16:36:05 -04:00
Pranav Srinivas Kumar
2c71311b5f
Update README.md 2019-06-09 12:31:58 -04:00
Pranav Srinivas Kumar
6e69548d82
Addresses Issue #25 2019-06-06 21:30:31 -04:00
Pranav Srinivas Kumar
2125f34d35
Update README.md 2019-06-05 15:48:12 -04:00
Pranav Srinivas Kumar
3ff61cce4b
Fixes Issue #23 2019-06-05 15:30:08 -04:00
Pranav Srinivas Kumar
374c70e7b3
Fixes issue #8 2019-05-01 20:13:10 -04:00
Pranav Srinivas Kumar
a80b960ea3
Update README.md 2019-04-28 19:30:52 -04:00
Pranav Srinivas Kumar
f011fd35ff
Update README.md 2019-04-24 14:17:55 -04:00
Pranav Srinivas Kumar
b35cee19e2
Update README.md 2019-04-19 21:09:17 -04:00
Pranav Srinivas Kumar
a60cb8baa2
Update README.md 2019-04-09 15:04:03 -04:00
Pranav Srinivas Kumar
bf3f582740
Update README.md 2019-04-09 14:55:08 -04:00
Pranav Srinivas Kumar
bc4eddc138
Update README.md 2019-04-09 07:46:47 -04:00
Pranav Srinivas Kumar
29f0c52f5f
Update README.md 2019-04-02 07:21:14 -04:00
Pranav Srinivas Kumar
ba8af57470
Update README.md 2019-04-01 23:47:49 -04:00
Pranav Srinivas Kumar
ad016b3c6e
Update README.md 2019-04-01 23:45:25 -04:00
Pranav Srinivas Kumar
c3e4853729
Update README.md 2019-04-01 23:31:27 -04:00
Pranav Srinivas Kumar
9ffa511dac
Update README.md 2019-04-01 23:28:17 -04:00
Pranav Srinivas Kumar
11729b4dfe
Update README.md 2019-04-01 21:53:04 -04:00
Pranav Srinivas Kumar
2bc003018d
Update README.md 2019-04-01 21:43:55 -04:00
Pranav Srinivas Kumar
63309d3e2a
Update README.md 2019-04-01 20:53:04 -04:00