redmine-api-cpp/src/Redmine-CLI/Redmine.hpp

108 lines
3.3 KiB
C++

#pragma once
/*
* Copyright (C) 2024 Dominik Meyer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "Redmine-CLI/Command/MyAccount.hpp"
#include "Redmine-CLI/Command/Version.hpp"
#include <CLI/App.hpp>
#include <CLI/Option.hpp>
#include <memory>
namespace RedmineCLI
{
/**
* @brief Main class for the CLI appication
*
* This class holds the main CLI::APP context and
* initializes commands for the application.
*
*/
class Redmine
{
private:
/// Main CLI11 application context
CLI::App &cli_;
/// CLI option for getting the redmine api token
CLI::Option *CLIredmineApiToken_;
/// CLI option for getting the redmine url
CLI::Option *CLIredmineUrl_;
/// the redmine api token itself
std::string redmineApiToken_;
/// the redmine url itself
std::string redmineUrl_;
/// pointer to the version subcommand
std::unique_ptr<Command::Version> version_;
/// pointer to the myAccount subcommand
std::unique_ptr<Command::MyAccount> myAccount_;
public:
/**
* @brief Main constructor for just creating an object and providing the main CLI::App Context
*
* @param cli - the CLI::App context
*/
explicit Redmine(CLI::App &cli);
/**
* @brief return the CLI::App context as a reference
*
* @return CLI::App&
*/
CLI::App & getCLI() const {return cli_;}
/**
* @brief Return a pointer to the CLI::Option for the redmine app token
*
* This is helpful as you can make it needed in a subcommand of the application.
*
* @return CLI::Option*
*/
CLI::Option* getTokenOption() { return CLIredmineApiToken_;}
/**
* @brief Return a pointer to the CLI::Option for the redmine url
*
* This is helpful as you can make it needed in a subcommand of the application.
*
* @return CLI::Option*
*/
CLI::Option* getUrlOption() { return CLIredmineUrl_;}
/**
* @brief return the parsed app token
*
* @return std::string
*/
std::string getToken() {return redmineApiToken_;}
/**
* @brief return the parsed redmine url
*
* @return std::string
*/
std::string getUrl() {return redmineUrl_;}
}; // class Redmine
}; // namespace RedmineCLI