FERS 1.0.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
arg_parser.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-only
2//
3// Copyright (c) 2024-present FERS Contributors (see AUTHORS.md).
4//
5// See the GNU GPLv2 LICENSE file in the FERS project root for more information.
6
7/**
8 * @file arg_parser.h
9 * @brief Command-line argument parsing utilities for the application.
10 *
11 * This header file provides utilities for parsing command-line arguments,
12 * displaying help, version information, and configuring the application via a configuration structure.
13 */
14
15#pragma once
16
17#include <expected>
18#include <libfers/api.h>
19#include <optional>
20#include <string>
21#include <thread>
22
23namespace core
24{
25 /**
26 * @class Config
27 * @brief Configuration structure for the application.
28 */
29 struct Config
30 {
31 std::string script_file; ///< Path to the script file.
33 unsigned num_threads = std::thread::hardware_concurrency(); ///< Number of threads to use.
34 bool validate = true; ///< Validate the input .fersxml file by default.
35 std::optional<std::string> log_file; ///< Optional log file path for logging output.
36 bool generate_kml = false; ///< Optional flag to generate KML visualization output.
37 };
38
39 /**
40 * @brief Displays the help message.
41 *
42 * @param programName The name of the program.
43 */
44 void showHelp(const char* programName) noexcept;
45
46 /**
47 * @brief Displays the version information.
48 */
49 void showVersion() noexcept;
50
51 /**
52 * @brief Parses command-line arguments.
53 *
54 * Processes the command-line arguments, validating them and extracting
55 * configurations like script file, logging level, and thread count.
56 *
57 * @param argc The argument count.
58 * @param argv The argument vector.
59 * @return std::expected<Config, std::string> Parsed configuration or an error message.
60 */
61 std::expected<Config, std::string> parseArguments(int argc, char* argv[]) noexcept;
62}
fers_log_level_t
Log levels for the FERS library.
Definition api.h:76
@ FERS_LOG_INFO
Definition api.h:79
void showVersion() noexcept
Displays the version information.
std::expected< Config, std::string > parseArguments(const int argc, char *argv[]) noexcept
Parses command-line arguments.
void showHelp(const char *programName) noexcept
Displays the help message.
Configuration structure for the application.
Definition arg_parser.h:30
std::string script_file
Path to the script file.
Definition arg_parser.h:31
fers_log_level_t log_level
Logging level.
Definition arg_parser.h:32
bool validate
Validate the input .fersxml file by default.
Definition arg_parser.h:34
bool generate_kml
Optional flag to generate KML visualization output.
Definition arg_parser.h:36
unsigned num_threads
Number of threads to use.
Definition arg_parser.h:33
std::optional< std::string > log_file
Optional log file path for logging output.
Definition arg_parser.h:35