summaryrefslogtreecommitdiff
path: root/src/command.h
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2023-04-01 14:16:44 +0200
committerEugen Wissner <belka@caraus.de>2023-04-01 14:17:08 +0200
commitf46a16b4a0d50b6512df2b312f7f800a9a963ca2 (patch)
tree8b385dc31c90065ba8e5a970dec9c931d68b7f43 /src/command.h
parent0385dbbe53cbeb89b541fa6ae659540a261bc69b (diff)
downloadslackbuilder-f46a16b4a0d50b6512df2b312f7f800a9a963ca2.tar.gz
Add an utility to list all installed packages
Diffstat (limited to 'src/command.h')
-rw-r--r--src/command.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/command.h b/src/command.h
new file mode 100644
index 0000000..8d0679d
--- /dev/null
+++ b/src/command.h
@@ -0,0 +1,48 @@
+#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);
+}