added printing default messages
48926f6 parent: 33742aa modified
app/include/output.hpp +3 -0 | @@ -15,4 +15,7 @@ public: | ||
| 15 | 15 | if (debugRun) |
| 16 | 16 | std::cerr << message << std::endl; |
| 17 | 17 | } |
| 18 | + auto printMessage(std::string message) -> void { | |
| 19 | + std::cout << message << std::endl; | |
| 20 | + } | |
| 18 | 21 | }; |
| \ No newline at end of file | ||
| @@ -15,4 +15,7 @@ public: | |||
| 15 | if (debugRun) | 15 | if (debugRun) |
| 16 | std::cerr << message << std::endl; | 16 | std::cerr << message << std::endl; |
| 17 | } | 17 | } |
| 18 | + auto printMessage(std::string message) -> void { | ||
| 19 | + std::cout << message << std::endl; | ||
| 20 | + } | ||
| 18 | }; | 21 | }; |
| \ No newline at end of file | \ No newline at end of file | ||
modified
app/src/main.cpp +11 -11 | @@ -18,14 +18,14 @@ | ||
| 18 | 18 | |
| 19 | 19 | #include <game.hpp> |
| 20 | 20 | #include <database.hpp> |
| 21 | +#include <output.hpp> | |
| 21 | 22 | |
| 22 | 23 | using namespace ftxui; |
| 23 | 24 | |
| 24 | - | |
| 25 | +Output output{}; | |
| 25 | 26 | std::string version{ "v0.1.2" }; |
| 26 | 27 | std::vector<Game> games; |
| 27 | 28 | |
| 28 | -bool debugRun = false; | |
| 29 | 29 | |
| 30 | 30 | auto addGame(Database& database, std::string name, std::string path) -> void { |
| 31 | 31 | std::string command = |
| @@ -81,17 +81,17 @@ auto handleCommand(const std::string& command, const std::vector<std::string>& a | ||
| 81 | 81 | runGame(gameName); |
| 82 | 82 | } |
| 83 | 83 | else if (command == "--version") { |
| 84 | - std::cout << "fluffy " + version << std::endl; | |
| 84 | + output.printMessage("fluffy " + version); | |
| 85 | 85 | } |
| 86 | 86 | else if (command == "--help") { |
| 87 | - std::cout << "fluffy commands:" << std::endl; | |
| 88 | - std::cout << " play <game_name> Runs a game" << std::endl; | |
| 89 | - std::cout << " add <game_name> <game_path> Add a game library" << std::endl; | |
| 90 | - std::cout << " show Show all games added to library" << std::endl; | |
| 91 | - std::cout << " rm <game_name> Remove game from a library" << std::endl; | |
| 87 | + output.printMessage("fluffy commands:\n \ | |
| 88 | + play <game_name> Runs a game\n \ | |
| 89 | + add <game_name> <game_path> Add a game library\n \ | |
| 90 | + show Show all games added to library\n \ | |
| 91 | + rm <game_name> Remove game from a library"); | |
| 92 | 92 | } |
| 93 | 93 | else { |
| 94 | - std::cout << "fluffy: '" << command << "' is not a fluffy command. See 'fluffy --help'" << std::endl; | |
| 94 | + output.printMessage("fluffy: '" + command + "' is not a fluffy command. See 'fluffy --help'"); | |
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | |
| @@ -148,10 +148,10 @@ auto runConsoleApp() -> void { | ||
| 148 | 148 | auto handleFlags(std::vector<std::string> flags) -> void { |
| 149 | 149 | for (const auto& flag : flags) { |
| 150 | 150 | if (flag == "-test") { |
| 151 | - std::cout << "hello!" << std::endl; | |
| 151 | + output.printMessage("hello!"); | |
| 152 | 152 | } |
| 153 | 153 | else { |
| 154 | - std::cout << "unkown option: '" << flag << "'" << std::endl; | |
| 154 | + output.printMessage("unkown option: '" + flag + "'"); | |
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | 157 | } |
| @@ -18,14 +18,14 @@ | |||
| 18 | 18 | ||
| 19 | #include <game.hpp> | 19 | #include <game.hpp> |
| 20 | #include <database.hpp> | 20 | #include <database.hpp> |
| 21 | +#include <output.hpp> | ||
| 21 | 22 | ||
| 22 | using namespace ftxui; | 23 | using namespace ftxui; |
| 23 | 24 | ||
| 24 | - | 25 | +Output output{}; |
| 25 | std::string version{ "v0.1.2" }; | 26 | std::string version{ "v0.1.2" }; |
| 26 | std::vector<Game> games; | 27 | std::vector<Game> games; |
| 27 | 28 | ||
| 28 | -bool debugRun = false; | ||
| 29 | 29 | ||
| 30 | auto addGame(Database& database, std::string name, std::string path) -> void { | 30 | auto addGame(Database& database, std::string name, std::string path) -> void { |
| 31 | std::string command = | 31 | std::string command = |
| @@ -81,17 +81,17 @@ auto handleCommand(const std::string& command, const std::vector<std::string>& a | |||
| 81 | runGame(gameName); | 81 | runGame(gameName); |
| 82 | } | 82 | } |
| 83 | else if (command == "--version") { | 83 | else if (command == "--version") { |
| 84 | - std::cout << "fluffy " + version << std::endl; | 84 | + output.printMessage("fluffy " + version); |
| 85 | } | 85 | } |
| 86 | else if (command == "--help") { | 86 | else if (command == "--help") { |
| 87 | - std::cout << "fluffy commands:" << std::endl; | 87 | + output.printMessage("fluffy commands:\n \ |
| 88 | - std::cout << " play <game_name> Runs a game" << std::endl; | 88 | + play <game_name> Runs a game\n \ |
| 89 | - std::cout << " add <game_name> <game_path> Add a game library" << std::endl; | 89 | + add <game_name> <game_path> Add a game library\n \ |
| 90 | - std::cout << " show Show all games added to library" << std::endl; | 90 | + show Show all games added to library\n \ |
| 91 | - std::cout << " rm <game_name> Remove game from a library" << std::endl; | 91 | + rm <game_name> Remove game from a library"); |
| 92 | } | 92 | } |
| 93 | else { | 93 | else { |
| 94 | - std::cout << "fluffy: '" << command << "' is not a fluffy command. See 'fluffy --help'" << std::endl; | 94 | + output.printMessage("fluffy: '" + command + "' is not a fluffy command. See 'fluffy --help'"); |
| 95 | } | 95 | } |
| 96 | } | 96 | } |
| 97 | 97 | ||
| @@ -148,10 +148,10 @@ auto runConsoleApp() -> void { | |||
| 148 | auto handleFlags(std::vector<std::string> flags) -> void { | 148 | auto handleFlags(std::vector<std::string> flags) -> void { |
| 149 | for (const auto& flag : flags) { | 149 | for (const auto& flag : flags) { |
| 150 | if (flag == "-test") { | 150 | if (flag == "-test") { |
| 151 | - std::cout << "hello!" << std::endl; | 151 | + output.printMessage("hello!"); |
| 152 | } | 152 | } |
| 153 | else { | 153 | else { |
| 154 | - std::cout << "unkown option: '" << flag << "'" << std::endl; | 154 | + output.printMessage("unkown option: '" + flag + "'"); |
| 155 | } | 155 | } |
| 156 | } | 156 | } |
| 157 | } | 157 | } |