Files
IAEngine/CLI/Src/Imp/CPP/CLI.cpp
Isuru Samarathunga 8afe023901 Fixes
2025-10-10 13:30:29 +05:30

76 lines
2.9 KiB
C++

// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <CLI.hpp>
#include <IACore/File.hpp>
#include <filesystem>
namespace ia::iae
{
#define REPORT_STATUS(...) printf(__CC_MAGENTA "%s" __CC_DEFAULT "\n", BuildString(__VA_ARGS__).c_str())
#define REPORT_ERROR(...) printf(__CC_RED "%s" __CC_DEFAULT "\n", BuildString(__VA_ARGS__).c_str())
#define REPORT_SUCCESS(...) printf(__CC_GREEN "%s" __CC_DEFAULT "\n", BuildString(__VA_ARGS__).c_str())
CLI::CLI() : ia::CLI("IAEngine CLI", IA_MAKE_VERSION(1, 0, 0), "Copyright (C) 2025 IASoft (PVT) LTD")
{
RegisterCommand({
.ID = "new",
.Shorthand = 'n',
.Help = "Creates a new game project",
.Parameters =
{
{
.ID = "name",
.Help = "Name of the project to be created",
.IsOptional = false,
.Type = ParameterValueType::STRING,
},
},
.Action = [&](IN Map<String, ParameterValue>&& params, IN Map<String, BOOL>&& switches)
{
try {
CreateNewProject(params["name"].StringValue);
} catch(CONST std::exception& e) {
IAE_LOG_ERROR("EXCEPTION: ", e.what());
return -4;
}
return 0;
},
});
// RegisterCommand({.ID = "run", .Shorthand = 'r', .Help = ""});
// RegisterCommand({.ID = "debug", .Shorthand = 'd', .Help = ""});
// RegisterCommand({.ID = "clean", .Shorthand = 'c', .Help = ""});
// RegisterCommand({.ID = "build", .Shorthand = 'b', .Help = ""});
// RegisterCommand({.ID = "rebuild", .Shorthand = 'e', .Help = ""});
// RegisterCommand({.ID = "package", .Shorthand = 'p', .Help = ""});
}
VOID CLI::CreateNewProject(IN CONST String& name)
{
if(std::filesystem::exists(name.c_str()))
{
REPORT_ERROR("Directory \"", name, "\" already exists. Aborting..");
return;
}
REPORT_STATUS("Creating Project ", name, "..");
std::filesystem::create_directories(name.c_str());
}
} // namespace ia::iae