|
1 | 1 | #include <iostream> |
2 | 2 | #include "download.h" |
| 3 | +#include "file_editor.h" |
| 4 | +#include "console.h" |
| 5 | +#include <vector> |
| 6 | + |
| 7 | +using namespace std; |
3 | 8 |
|
4 | 9 | int main() { |
5 | | - const Download downloader( |
6 | | - "https://eztxm.de/assets/images/logo.png", |
7 | | - "/Users/eztxmmc/Downloads/logo.png" |
8 | | - ); |
9 | | - if (downloader.download()) { |
10 | | - std::cout << "Logo loaded successfully!" << std::endl; |
11 | | - return 0; |
12 | | - } |
13 | | - std::cerr << "Error loading logo" << std::endl; |
14 | | - return 1; |
| 10 | + vector<string> enviroments = {"client", "server"}; |
| 11 | + cout << "Welcome to the Minecraft Modpack Downloader!" << endl; |
| 12 | + cout << "------------------------------------------" << endl; |
| 13 | + cout << "This program will download a Minecraft modpack from a given URL." << endl; |
| 14 | + cout << "------------------------------------------" << endl; |
| 15 | + const filesystem::path path = request_input("Enter path to download to: "); |
| 16 | + const string zipName = request_input("Enter zip name: ") + ".zip"; |
| 17 | + const string url = request_input("Enter URL to download from: "); |
| 18 | + string enviroment; |
| 19 | + while (find(enviroments.begin(), enviroments.end(), enviroment) == enviroments.end()) { |
| 20 | + enviroment = request_input("Enter environment to download for: "); |
| 21 | + if (find(enviroments.begin(), enviroments.end(), enviroment) == enviroments.end()) { |
| 22 | + cerr << "Invalid environment, please enter either 'client' or 'server'" << endl; |
| 23 | + cout << "------------------------------------------" << endl; |
| 24 | + cout << "Press enter to reenter environment..."; |
| 25 | + cin.get(); |
| 26 | + cin.ignore(); |
| 27 | + cout << "------------------------------------------" << endl; |
| 28 | + } |
| 29 | + } |
| 30 | + if (find(enviroments.begin(), enviroments.end(), enviroment) == enviroments.end()) { |
| 31 | + cerr << "Invalid environment, please enter either 'client' or 'server'" << endl; |
| 32 | + return 1; |
| 33 | + } |
| 34 | + cout << endl; |
| 35 | + filesystem::path zipPath = path / zipName; |
| 36 | + if (const Download downloader(url, zipPath); !downloader.download()) { |
| 37 | + cerr << "Error downloading " << url << endl; |
| 38 | + return 1; |
| 39 | + } |
| 40 | + cout << url << " loaded successfully!" << endl; |
| 41 | + const FileEditor editor(path); |
| 42 | + editor.removeDirectory("config"); |
| 43 | + editor.removeDirectory("defaultconfigs"); |
| 44 | + editor.removeDirectory("kubejs"); |
| 45 | + editor.removeDirectory("logs"); |
| 46 | + editor.removeDirectory("mods"); |
| 47 | + if (enviroment == "client") { |
| 48 | + editor.removeDirectory("resourcepacks"); |
| 49 | + editor.removeDirectory("shaderpacks"); |
| 50 | + } |
| 51 | + |
| 52 | + return 0; |
15 | 53 | } |
0 commit comments