kaycxx-cli
C++ CLI library
Loading...
Searching...
No Matches
option_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 <utility>
12
13#include <kaycxx/cli/option.hpp>
14
15namespace kaycxx::cli {
16
24template <parseable_value T>
26public:
33 definition_->mark_as_action();
34 return *this;
35 }
36
45 definition_->mark_as_required();
46 return *this;
47 }
48
55 return *definition_;
56 }
57
70 definition_->default_value(std::move(value));
71 return *this;
72 }
73
74private:
75 friend class command;
76
83 : definition_(&definition)
84 {}
85
87 option<T>* definition_;
88};
89
90} // namespace kaycxx::cli
Common base class for an application and its commands.
Definition command.hpp:45
Handle for a registered option.
Definition option_handle.hpp:25
option_handle action() noexcept
Marks the option as a mutually exclusive command action.
Definition option_handle.hpp:32
option< T > const & definition() const noexcept
Returns the underlying option definition.
Definition option_handle.hpp:54
option_handle default_value(T value)
Sets the default option value.
Definition option_handle.hpp:69
option_handle required()
Requires the option to be specified explicitly.
Definition option_handle.hpp:44
Defines command line options.