6 #ifndef MOTORCORTEX_CORE_CMDLINE_CONFIG_H
7 #define MOTORCORTEX_CORE_CMDLINE_CONFIG_H
9 #include "cm_conndata.h"
10 #include "cmdline_field.h"
11 #include "cmdline_helper.h"
12 #include "cmdline_realtime.h"
13 #include "cmdline_systemmode.h"
14 #include "cmdline_task.h"
20 namespace mcx::cmd_line {
30 const static std::map<std::string, FieldDesc> FIELDS;
35 explicit Config(std::vector<Component> components);
37 Config(std::vector<Component> components, SystemMode mode);
41 bool load(
const std::string& file);
43 std::string version()
const;
45 std::string toString()
const;
50 T get(
const std::string& name)
const {
51 return mcx::cmd_line::get<T>(config_, {name, Field::Required, Container::Any, DataType::Any}, path_);
54 std::string path(std::string path)
const;
56 Task task(std::string path)
const;
58 Server server(std::string path)
const;
60 SystemMode mode(std::string path = {})
const;
62 SystemMode systemMode(std::string path = {})
const;
64 Realtime realtime(std::string path = {})
const;
66 nlohmann::json find(
const std::string& path)
const;
69 std::shared_ptr<license::License> license_;
71 static container::TaskSched getTaskSched(std::string task_sched);
73 static std::tuple<std::string, std::string, std::string, std::string> parseUrl(std::string url);
75 static inline std::string makePath(
const std::string& field_name,
const std::string& path) {
76 if (!path.empty() && path[0] !=
'/') {
77 return fmt::format(
"{}/{}", field_name, path);
83 nlohmann::json config_;
84 std::vector<Component> components_;
85 SystemMode cmd_mode_{SystemMode::PRODUCTION};
88 std::string path(
const std::string&);
90 std::string filename(
const std::string& path);
92 Config parse(
int argc,
char** argv, std::vector<Component> component = {});
96 #endif // MOTORCORTEX_CORE_CMDLINE_CONFIG_H