49 lines
1.0 KiB
C++
49 lines
1.0 KiB
C++
#include <iostream>
|
|
#include <cstring>
|
|
#include <memory>
|
|
#include <vector>
|
|
#include "package.h"
|
|
|
|
namespace katja
|
|
{
|
|
class command
|
|
{
|
|
public:
|
|
virtual void execute() const = 0;
|
|
};
|
|
|
|
class list final : public command
|
|
{
|
|
public:
|
|
void execute() const override;
|
|
};
|
|
|
|
class help final : public command
|
|
{
|
|
public:
|
|
void execute() const override;
|
|
};
|
|
|
|
enum class command_exception_t
|
|
{
|
|
no_command,
|
|
too_many_arguments,
|
|
unknown_command,
|
|
};
|
|
|
|
class command_exception final : public std::exception
|
|
{
|
|
command_exception_t m_exception_type;
|
|
std::vector<std::string> m_failed_arguments;
|
|
|
|
public:
|
|
explicit command_exception(const command_exception_t exception_type,
|
|
std::vector<std::string> failed_arguments = {}) noexcept;
|
|
|
|
const char *what() const noexcept override;
|
|
const std::vector<std::string>& failed_arguments() const noexcept;
|
|
};
|
|
|
|
std::unique_ptr<command> parse_command_line(int argc, char **argv);
|
|
}
|