$darkmode
main_commands.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2023 Robert Bosch GmbH
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * SPDX-License-Identifier: Apache-2.0
17  */
23 #include <optional>
24 #include <string>
25 #include <vector>
26 
27 #include <cloe/stack_config.hpp>
28 #include <cloe/stack_factory.hpp>
29 
30 #include "lua_setup.hpp"
31 
32 namespace engine {
33 
34 struct CheckOptions {
35  cloe::StackOptions stack_options;
36  cloe::LuaOptions lua_options;
37 
38  std::ostream* output = &std::cout;
39  std::ostream* error = &std::cerr;
40  std::string delimiter = ",";
41 
42  // Flags:
43  bool summarize = false;
44  bool output_json = false;
45  int json_indent = 2;
46 };
47 
48 int check(const CheckOptions& opt, const std::vector<std::string>& filepaths);
49 
50 struct DumpOptions {
51  cloe::StackOptions stack_options;
52  cloe::LuaOptions lua_options;
53 
54  std::ostream* output = &std::cout;
55  std::ostream* error = &std::cerr;
56 
57  // Flags:
58  int json_indent = 2;
59 };
60 
61 int dump(const DumpOptions& opt, const std::vector<std::string>& filepaths);
62 
63 struct ProbeOptions {
64  cloe::StackOptions stack_options;
65  cloe::LuaOptions lua_options;
66 
67  std::ostream* output = &std::cout;
68  std::ostream* error = &std::cerr;
69 
70  // Options
71  std::string uuid; // Not currently used.
72 
73  // Flags:
74  int json_indent = 2;
75 
76  bool debug_lua = false; // Not currently used.
77  int debug_lua_port = CLOE_LUA_DEBUGGER_PORT; // Not currently used.
78 };
79 
80 int probe(const ProbeOptions& opt, const std::vector<std::string>& filepaths);
81 
82 struct RunOptions {
83  cloe::StackOptions stack_options;
84  cloe::LuaOptions lua_options;
85 
86  std::ostream* output = &std::cout;
87  std::ostream* error = &std::cerr;
88 
89  // Options
90  std::string uuid;
91  std::string output_path;
92 
93  // Flags:
94  int json_indent = 2;
95  bool allow_empty = false;
96  bool write_output = true;
97  bool require_success = false;
98  bool report_progress = true;
99 
100  bool debug_lua = false;
101  int debug_lua_port = CLOE_LUA_DEBUGGER_PORT;
102 };
103 
104 int run(const RunOptions& opt, const std::vector<std::string>& filepaths);
105 
106 struct ShellOptions {
107  cloe::StackOptions stack_options;
108  cloe::LuaOptions lua_options;
109 
110  std::ostream* output = &std::cout;
111  std::ostream* error = &std::cerr;
112 
113  // Options:
114  std::vector<std::string> commands;
115 
116  // Flags:
117  std::optional<bool> interactive;
118  bool ignore_errors;
119 };
120 
121 int shell(const ShellOptions& opt, const std::vector<std::string>& filepaths);
122 
123 struct UsageOptions {
124  cloe::StackOptions stack_options;
125  cloe::LuaOptions lua_options;
126 
127  std::ostream* output = &std::cout;
128  std::ostream* error = &std::cerr;
129 
130  // Flags:
131  bool plugin_usage = false;
132  bool output_json = false;
133  int json_indent = 2;
134 };
135 
136 int usage(const UsageOptions& opt, const std::string& argument);
137 
139  std::ostream* output = &std::cout;
140  std::ostream* error = &std::cerr;
141 
142  // Flags:
143  bool output_json = false;
144  int json_indent = 2;
145 };
146 
147 int version(const VersionOptions& opt);
148 
149 // ------------------------------------------------------------------------- //
150 
151 class Simulation;
152 
153 extern Simulation* GLOBAL_SIMULATION_INSTANCE; // NOLINT
154 
170 void handle_signal(int sig);
171 
172 } // namespace engine
Definition: simulation.hpp:39
void handle_signal(int sig)
Definition: main_commands.cpp:51
Definition: lua_setup.hpp:42
Definition: main_commands.hpp:34
Definition: main_commands.hpp:50
Definition: main_commands.hpp:63
Definition: main_commands.hpp:82
Definition: main_commands.hpp:106
Definition: main_commands.hpp:123
Definition: main_commands.hpp:138