2025-04-30 17:01:34 +02:00
|
|
|
#include "CLI11.hpp"
|
|
|
|
|
#include "init.h"
|
|
|
|
|
#include "logger.h"
|
2025-07-15 18:02:13 +02:00
|
|
|
#include "module.h"
|
|
|
|
|
#include "pipeline.h"
|
2025-05-06 20:16:15 +02:00
|
|
|
#include "probe.h"
|
2025-05-24 20:59:22 +02:00
|
|
|
#include "process.h"
|
2025-07-15 18:02:13 +02:00
|
|
|
#include "run_as.h"
|
2025-04-30 17:01:34 +02:00
|
|
|
#include "satdump_vars.h"
|
2025-07-15 18:02:13 +02:00
|
|
|
#include "subcommand.h"
|
2025-04-30 18:16:46 +02:00
|
|
|
#include <memory>
|
|
|
|
|
|
2025-04-30 17:01:34 +02:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
// Init logger
|
|
|
|
|
initLogger();
|
|
|
|
|
|
|
|
|
|
// Basic flags
|
|
|
|
|
bool verbose = false;
|
|
|
|
|
for (int i = 0; i < argc; i++)
|
|
|
|
|
if (std::string(argv[i]) == "-v" || std::string(argv[i]) == "--verbose")
|
|
|
|
|
verbose = true;
|
|
|
|
|
|
2025-07-15 18:02:13 +02:00
|
|
|
// Init SatDump, silent or verbose as requested
|
2025-04-30 17:01:34 +02:00
|
|
|
if (!verbose)
|
|
|
|
|
logger->set_level(slog::LOG_WARN);
|
|
|
|
|
satdump::initSatdump();
|
|
|
|
|
completeLoggerInit();
|
|
|
|
|
if (!verbose)
|
|
|
|
|
logger->set_level(slog::LOG_TRACE);
|
|
|
|
|
|
2025-07-15 18:02:13 +02:00
|
|
|
// Command basics
|
2025-04-30 17:01:34 +02:00
|
|
|
CLI::App app("SatDump v" + satdump::SATDUMP_VERSION);
|
|
|
|
|
app.set_help_all_flag("--help-all", "Expand all help");
|
|
|
|
|
app.add_flag("-v,--verbose", verbose, "Make the logger more verbose");
|
|
|
|
|
app.require_subcommand();
|
|
|
|
|
|
2025-07-15 18:02:13 +02:00
|
|
|
// All possible subcommands
|
|
|
|
|
std::vector<std::shared_ptr<satdump::CmdHandler>> cmd_handlers;
|
2025-04-30 18:16:46 +02:00
|
|
|
|
2025-07-15 18:02:13 +02:00
|
|
|
cmd_handlers.push_back(std::make_shared<satdump::ScriptCmdHandler>());
|
|
|
|
|
cmd_handlers.push_back(std::make_shared<satdump::ModuleCmdHandler>());
|
|
|
|
|
cmd_handlers.push_back(std::make_shared<satdump::ProbeCmdHandler>());
|
|
|
|
|
cmd_handlers.push_back(std::make_shared<satdump::PipelineCmdHandler>());
|
|
|
|
|
cmd_handlers.push_back(std::make_shared<satdump::ProcessCmdHandler>());
|
2025-04-30 17:01:34 +02:00
|
|
|
|
2025-07-15 18:02:13 +02:00
|
|
|
for (auto &c : cmd_handlers)
|
|
|
|
|
c->reg(&app);
|
2025-05-24 20:59:22 +02:00
|
|
|
|
2025-04-30 17:01:34 +02:00
|
|
|
CLI11_PARSE(app, argc, argv);
|
|
|
|
|
|
|
|
|
|
for (auto *subcom : app.get_subcommands())
|
|
|
|
|
{
|
2025-05-02 14:17:47 +02:00
|
|
|
// std::cout << "Subcommand: " << subcom->get_name() << '\n';
|
2025-04-30 18:16:46 +02:00
|
|
|
|
2025-07-15 18:02:13 +02:00
|
|
|
for (auto &c : cmd_handlers)
|
|
|
|
|
if (subcom->get_name() == c->cmd)
|
2025-07-16 07:55:34 +02:00
|
|
|
c->run(&app, subcom);
|
2025-04-30 17:01:34 +02:00
|
|
|
}
|
|
|
|
|
}
|