This repository has been archived by the owner on Oct 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
81 lines (59 loc) · 2.19 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/**
* nxpinhum5326/pmmpBuilder alpha
*/
#include <iostream>
#include <fstream>
#include <string>
#include <filesystem>
namespace fs = std::filesystem;
class pmmpBuilder {
public:
void createProject(const std::string& destinationPath, const std::string& projectName, const std::string& namespaceName) {
fs::create_directory(destinationPath + "/" + projectName);
fs::create_directory(destinationPath + "/" + projectName + "/src");
std::string srcPath = destinationPath + "/" + projectName + "/src";
createNamespace(srcPath, namespaceName);
//main.php içeriği/content
std::string mainFileContent = R"(<?php
namespace )" + namespaceName + R"(;
use pocketmine\plugin\PluginBase;
class Main extends PluginBase {
}
)";
createFile(srcPath + "/" + namespaceName, "Main.php", mainFileContent);
//plugin.yml içeriği/content
std::string yamlFileContent = R"(name: )" + projectName + R"(
version: 1.0.0
api: 5.0.0
author: )" + namespaceName + R"(
main: )" + namespaceName + R"(\Main
)";
createFile(destinationPath + "/" + projectName, "plugin.yml", yamlFileContent);
}
private:
void createNamespace(const std::string& path, const std::string& namespaceName) {
fs::create_directory(path + "/" + namespaceName);
}
void createFile(const std::string& path, const std::string& filename, const std::string& content) {
std::ofstream file(path + "/" + filename);
file << content;
file.close();
}
};
int main() {
pmmpBuilder builder;
//şimdilik bu kadar basit bir kullanım :c
std::string prefix = "pmmpBuilder ALPHA > ";
std::string destination;
std::string projectName;
std::string namespaceName;
std::cout << prefix << "Where the project will be created(destination path): ";
std::getline(std::cin, destination);
std::cout << prefix << "Project/Plugin name: ";
std::getline(std::cin, projectName);
std::cout << prefix << "Namespace/Author(for now) name: ";
std::getline(std::cin, namespaceName);
builder.createProject(destination, projectName, namespaceName);
std::cout << "pmmpBuilder > Plugin basement created." << std::endl;
return 0;
}