kaycxx-cli
C++ CLI library
Loading...
Searching...
No Matches
parameters_handle.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Klaus Reimer <k@ailis.de>
2// SPDX-License-Identifier: MIT
3
9#pragma once
10
11#include <cstddef>
12#include <initializer_list>
13#include <utility>
14#include <vector>
15
17
18namespace kaycxx::cli {
19
27template <parseable_value T>
29public:
36 return *definition_;
37 }
38
46 parameters_handle min(std::size_t count) noexcept {
47 definition_->min(count);
48 return *this;
49 }
50
58 parameters_handle max(std::size_t count) noexcept {
59 definition_->max(count);
60 return *this;
61 }
62
73 definition_->default_values(std::move(values));
74 return *this;
75 }
76
86 parameters_handle default_values(std::initializer_list<T> values) {
87 definition_->default_values(std::vector<T>(values));
88 return *this;
89 }
90
91private:
92 friend class command;
93
100 : definition_(&definition)
101 {}
102
104 parameters<T>* definition_;
105};
106
107} // namespace kaycxx::cli
Defines and parses a command line interface.
Definition command.hpp:68
Handle for a registered option.
Definition option_handle.hpp:25
Handle for a registered positional parameter list.
Definition parameters_handle.hpp:28
parameters_handle default_values(std::vector< T > values)
Sets default values for the parameter list.
Definition parameters_handle.hpp:72
parameters< T > const & definition() const noexcept
Returns the underlying parameter list definition.
Definition parameters_handle.hpp:35
parameters_handle max(std::size_t count) noexcept
Sets the maximum number of values accepted by the parameter list.
Definition parameters_handle.hpp:58
parameters_handle default_values(std::initializer_list< T > values)
Sets default values for the parameter list.
Definition parameters_handle.hpp:86
parameters_handle min(std::size_t count) noexcept
Sets the minimum number of values accepted by the parameter list.
Definition parameters_handle.hpp:46
Defines positional parameter lists.