NewProjectCmd.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #include <Atomic/Core/StringUtils.h>
  2. #include <Atomic/IO/Log.h>
  3. #include "NewProjectCmd.h"
  4. #include <Poco/File.h>
  5. namespace ToolCore
  6. {
  7. NewProjectCmd::NewProjectCmd(Context* context) : Command(context)
  8. {
  9. }
  10. NewProjectCmd::~NewProjectCmd()
  11. {
  12. }
  13. bool NewProjectCmd::Parse(const Vector<String>& arguments, unsigned startIndex, String& errorMsg)
  14. {
  15. String argument = arguments[startIndex].ToLower();
  16. String value = startIndex + 1 < arguments.Size() ? arguments[startIndex + 1] : String::EMPTY;
  17. if (argument != "new")
  18. {
  19. errorMsg = "Unable to parse new command";
  20. return false;
  21. }
  22. if (!value.Length())
  23. {
  24. errorMsg = "Unable to parse new project path";
  25. return false;
  26. }
  27. projectPath_ = value;
  28. return true;
  29. }
  30. void NewProjectCmd::Run()
  31. {
  32. Poco::File projectDest(projectPath_.CString());
  33. if (projectDest.exists())
  34. {
  35. Error(ToString("New project path: %s already exists", projectPath_.CString()));
  36. return;
  37. }
  38. LOGINFOF("Creating new project in: %s", projectPath_.CString());
  39. Finished();
  40. }
  41. }