Elaztek Developer Hub
Blamite Game Engine - Tool (Library)
A command-line utility that aids in the creation of Blamite Cache (.map) Files.
SetProjectCommand.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <Strings/components/utils/io/io.h>
4 #include <Strings/components/utils/string/string.h>
5 #include <Strings/components/utils/converters/converters.h>
6 #include <Strings/components/logger/logger.h>
7 
8 #include <HEKGuerilla/components/tags/importers/bitmap/bitmap.h>
9 #include <HEKGuerilla/components/tags/tags.h>
10 #include <HEKGuerilla/components/settings/config/config.h>
11 
12 #include "../ToolCommand.hpp"
13 #include "../console.h"
14 
15 #ifdef TOOL_LIB_EXPORTS
16 #define TOOL_LIB_API __declspec(dllexport)
17 #else
18 #define TOOL_LIB_API __declspec(dllimport)
19 #endif
20 
28 {
29 public:
31  {
32  command = "set-project";
33  syntax = "set-project [dir]";
34  description = "instructs tool to use a custom directory for all commands. if set, then all commands run will use the "
35  "specified directory when checking data, tags, and other content folders. if left blank, then any existing path "
36  "will be cleared, and the application directory will be used instead.";
37  }
38 
39  int execute(std::vector<std::string> args)
40  {
41  if (args.size() == 0)
42  {
43  BlamStrings::Logger::LogEvent("not enough arguments provided - you must specify a project root directory", WSV_WARNING);
44  return -1;
45  }
46 
47  if (!BlamStrings::Utils::IO::IsDirectory(args[0]))
48  {
49  BlamStrings::Logger::LogEvent("specified path '" + args[0] + "' does not exist, or is not a directory", WSV_WARNING);
50  return -1;
51  }
52 
53  std::string dir = BlamStrings::Utils::IO::GetAbsolutePathFromRelative(args[0]);
54 
55  if (BlamStrings::Utils::IO::CreateNewFile(".TOOL_PROJECT_ROOT", dir))
56  {
57  BlamStrings::Logger::LogEvent("successfully set project root to '" + dir + "'");
58  }
59  else
60  {
61  BlamStrings::Logger::LogEvent("could not change project root: CreateNewFile() returned false", WSV_WARNING);
62  return -1;
63  }
64 
65  return 0;
66  }
67 };
SetProjectCommand::SetProjectCommand
SetProjectCommand()
Definition: SetProjectCommand.hpp:30
SetProjectCommand
Class for the set-project command.
Definition: SetProjectCommand.hpp:27
ToolCommand::syntax
std::string syntax
The syntax of the command. This should include the command name, as well as any arguments.
Definition: ToolCommand.hpp:19
ToolCommand::command
std::string command
The name of the command.
Definition: ToolCommand.hpp:18
ToolCommand
Base class representing a Tool command.
Definition: ToolCommand.hpp:15
SetProjectCommand::execute
int execute(std::vector< std::string > args)
Executes the command.
Definition: SetProjectCommand.hpp:39
ToolCommand::description
std::string description
A description of the command.
Definition: ToolCommand.hpp:20