Branch data Line data Source code
1 : : // Copyright 2026 HPActor Contributors
2 : : //
3 : : // Licensed under the Apache License, Version 2.0 (the "License");
4 : : // you may not use this file except in compliance with the License.
5 : : // You may obtain a copy of the License at
6 : : //
7 : : // http://www.apache.org/licenses/LICENSE-2.0
8 : : //
9 : : // Unless required by applicable law or agreed to in writing, software
10 : : // distributed under the License is distributed on an "AS IS" BASIS,
11 : : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : : // See the License for the specific language governing permissions and
13 : : // limitations under the License.
14 : :
15 : : #pragma once
16 : :
17 : : #include <hpactor/types/types.hpp>
18 : : #include <map>
19 : : #include <optional>
20 : : #include <string>
21 : : #include <vector>
22 : :
23 : : namespace hpactor {
24 : :
25 : : class ActorSystem;
26 : :
27 : : namespace cli {
28 : :
29 : : class CliActor;
30 : : class OutputFormatter;
31 : :
32 : : struct CommandContext {
33 : : std::vector<std::string> args;
34 : : std::map<std::string, std::string> params;
35 : : ActorSystem* system = nullptr;
36 : : CliActor* cli_actor = nullptr;
37 : : OutputFormatter* output = nullptr;
38 : : bool paged = false;
39 : : uint32_t page_size = 50;
40 : : std::string format = "pretty";
41 : :
42 : 0 : bool has_flag(const std::string& name) const {
43 : 0 : auto it = params.find(name);
44 : 0 : return it != params.end() && (it->second == "true" || it->second.empty());
45 : : }
46 : :
47 : 0 : std::optional<std::string> get_param(const std::string& name) const {
48 : 0 : auto it = params.find(name);
49 : 0 : if (it != params.end()) return it->second;
50 : 0 : return std::nullopt;
51 : : }
52 : : };
53 : :
54 : : } // namespace cli
55 : : } // namespace hpactor
|