ORE Studio 0.0.4
Loading...
Searching...
No Matches
application.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2025 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef ORES_CLI_APP_APPLICATION_HPP
21#define ORES_CLI_APP_APPLICATION_HPP
22
23#include <vector>
24#include <ostream>
25#include <optional>
26#include <filesystem>
27#include "ores.logging/make_logger.hpp"
28#include "ores.database/domain/context.hpp"
29#include "ores.database/domain/database_options.hpp"
30#include "ores.cli/config/options.hpp"
31#include "ores.cli/config/import_options.hpp"
32#include "ores.cli/config/export_options.hpp"
33#include "ores.cli/config/delete_options.hpp"
34#include "ores.cli/config/add_options.hpp"
35#include "ores.cli/config/add_currency_options.hpp"
36#include "ores.cli/config/add_account_options.hpp"
37#include "ores.cli/config/add_feature_flag_options.hpp"
38#include "ores.cli/config/add_login_info_options.hpp"
39#include "ores.cli/config/add_role_options.hpp"
40#include "ores.cli/config/add_permission_options.hpp"
41#include "ores.cli/config/add_country_options.hpp"
42#include "ores.cli/config/add_change_reason_options.hpp"
43#include "ores.cli/config/add_change_reason_category_options.hpp"
44
45namespace ores::cli::app {
46
50class application final {
51private:
52 inline static std::string_view logger_name =
53 "ores.cli.application";
54
55 [[nodiscard]] static auto& lg() {
56 using namespace ores::logging;
57 static auto instance = make_logger(logger_name);
58 return instance;
59 }
60
61public:
62 explicit application(std::ostream& output_stream,
63 const std::optional<database::database_options>& db_opts);
64 application(const application&) = delete;
65 application& operator=(const application&) = delete;
66
67private:
69 make_context(const std::optional<database::database_options>& db_opts);
70 void import_currencies(const std::vector<std::filesystem::path> files) const;
71 void import_data(const std::optional<config::import_options>& ocfg) const;
72
73 void export_currencies(const config::export_options& cfg) const;
74 void export_accounts(const config::export_options& cfg) const;
75 void export_feature_flags(const config::export_options& cfg) const;
76 void export_login_info(const config::export_options& cfg) const;
77 void export_roles(const config::export_options& cfg) const;
78 void export_permissions(const config::export_options& cfg) const;
79 void export_countries(const config::export_options& cfg) const;
80 void export_change_reasons(const config::export_options& cfg) const;
81 void export_change_reason_categories(const config::export_options& cfg) const;
82 void export_data(const std::optional<config::export_options>& ocfg) const;
83
84 void delete_currency(const config::delete_options& cfg) const;
85 void delete_account(const config::delete_options& cfg) const;
86 void delete_feature_flag(const config::delete_options& cfg) const;
87 void delete_login_info(const config::delete_options& cfg) const;
88 void delete_role(const config::delete_options& cfg) const;
89 void delete_permission(const config::delete_options& cfg) const;
90 void delete_country(const config::delete_options& cfg) const;
91 void delete_change_reason(const config::delete_options& cfg) const;
92 void delete_change_reason_category(const config::delete_options& cfg) const;
93 void delete_data(const std::optional<config::delete_options>& ocfg) const;
94
95 void add_currency(const config::add_currency_options& cfg) const;
96 void add_account(const config::add_account_options& cfg) const;
97 void add_feature_flag(const config::add_feature_flag_options& cfg) const;
98 void add_login_info(const config::add_login_info_options& cfg) const;
99 void add_role(const config::add_role_options& cfg) const;
100 void add_permission(const config::add_permission_options& cfg) const;
101 void add_country(const config::add_country_options& cfg) const;
102 void add_change_reason(const config::add_change_reason_options& cfg) const;
103 void add_change_reason_category(const config::add_change_reason_category_options& cfg) const;
104 void add_data(const std::optional<config::add_options>& ocfg) const;
105
106public:
112 void run(const config::options& cfg) const;
113
114private:
115 database::context context_;
116 std::ostream& output_stream_;
117};
118
119}
120
121#endif
Application hosting infrastructure for the CLI tool.
Definition application.hpp:45
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Entry point for the ores command line application.
Definition application.hpp:50
void run(const config::options &cfg) const
Executes the application.
Definition application.cpp:521
Configuration for adding an account entity via command-line arguments.
Definition add_account_options.hpp:32
Configuration for adding a change reason category entity via command-line arguments.
Definition add_change_reason_category_options.hpp:32
Configuration for adding a change reason entity via command-line arguments.
Definition add_change_reason_options.hpp:32
Configuration for adding a country entity via command-line arguments.
Definition add_country_options.hpp:32
Configuration for adding a currency entity via command-line arguments.
Definition add_currency_options.hpp:32
Configuration for adding a feature flag entity via command-line arguments.
Definition add_feature_flag_options.hpp:32
Configuration for adding a login_info entity via command-line arguments.
Definition add_login_info_options.hpp:32
Configuration for adding a permission entity via command-line arguments.
Definition add_permission_options.hpp:32
Configuration for adding a role entity via command-line arguments.
Definition add_role_options.hpp:33
Configuration related to deleting entities.
Definition delete_options.hpp:32
Configuration related to exporting data into a supported export format.
Definition export_options.hpp:34
All of the configuration options required by the command line application.
Definition options.hpp:39
Context for the operations on a postgres database.
Definition context.hpp:30