cli20 0.1.2
A C++20 typed-schema command-line parser
Loading...
Searching...
No Matches
argument_base.hh
Go to the documentation of this file.
1#pragma once
2
3namespace cli {
4
7struct SpecMemberTag {};
8
11
14
17
21
28struct Nargs {
29 int min = 0;
30 int max = -1;
31};
32
36enum class Presence { required, optional };
37
39inline constexpr auto required = Presence::required;
40
42inline constexpr auto optional = Presence::optional;
43
44namespace nargs {
45
47inline constexpr Nargs none{.min = 0, .max = 0};
48
50inline constexpr Nargs one{.min = 1, .max = 1};
51
53inline constexpr Nargs zero_or_one{.min = 0, .max = 1};
54
56inline constexpr Nargs zero_or_more{.min = 0, .max = -1};
57
59inline constexpr Nargs one_or_more{.min = 1, .max = -1};
60
61template <int N>
62inline constexpr Nargs exactly{.min = N, .max = N};
63
64template <int Min, int Max>
65inline constexpr Nargs between{.min = Min, .max = Max};
66
67} // namespace nargs
68
69} // namespace cli
constexpr Nargs one_or_more
Accepts one or more values.
constexpr Nargs one
Accepts exactly one value.
constexpr Nargs none
Accepts no values; used for boolean flags.
constexpr Nargs zero_or_one
Accepts zero or one value.
constexpr Nargs exactly
constexpr Nargs zero_or_more
Accepts zero or more values.
constexpr Nargs between
Definition action.hh:29
constexpr auto optional
Convenience constant for Presence::optional.
constexpr auto required
Convenience constant for Presence::required.
Presence
Controls whether an option or positional argument is mandatory.
Tag base class for subcommand fields.
Tag base class for the Description field that provides the CLI's help text.
Specifies the minimum and maximum number of values an option or positional accepts.
int min
Minimum number of values (>= 0).
int max
Maximum number of values; -1 means unlimited.
Tag base class for command-line option/flag fields.
Tag base class for positional argument fields.
Base tag for all members that may appear in an argument specification struct.