CommandParser.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. //
  2. // Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
  3. // LICENSE: Atomic Game Engine Editor and Tools EULA
  4. // Please see LICENSE_ATOMIC_EDITOR_AND_TOOLS.md in repository root for
  5. // license information: https://github.com/AtomicGameEngine/AtomicGameEngine
  6. //
  7. #include "CommandParser.h"
  8. #include "NewProjectCmd.h"
  9. #include "PlatformAddCmd.h"
  10. #include "BuildCmd.h"
  11. #include "ImportCmd.h"
  12. #include "PlayCmd.h"
  13. #include "EditCmd.h"
  14. #include "BindCmd.h"
  15. #include "NETProjectGenCmd.h"
  16. namespace ToolCore
  17. {
  18. CommandParser::CommandParser(Context* context) : Object(context)
  19. {
  20. }
  21. CommandParser::~CommandParser()
  22. {
  23. }
  24. Command* CommandParser::Parse(const Vector<String>& arguments)
  25. {
  26. Command* cmd = NULL;
  27. for (unsigned i = 0; i < arguments.Size(); ++i)
  28. {
  29. if (arguments[i].Length())
  30. {
  31. String argument = arguments[i].ToLower();
  32. if (argument == "new")
  33. {
  34. cmd = new NewProjectCmd(context_);
  35. }
  36. else if (argument == "build")
  37. {
  38. cmd = new BuildCmd(context_);
  39. }
  40. else if (argument == "platform-add")
  41. {
  42. cmd = new PlatformAddCmd(context_);
  43. }
  44. else if (argument == "import")
  45. {
  46. cmd = new ImportCmd(context_);
  47. }
  48. else if (argument == "play")
  49. {
  50. cmd = new PlayCmd(context_);
  51. }
  52. else if (argument == "edit")
  53. {
  54. cmd = new EditCmd(context_);
  55. }
  56. else if (argument == "bind")
  57. {
  58. cmd = new BindCmd(context_);
  59. }
  60. else if (argument == "net-projectgen")
  61. {
  62. cmd = new NETProjectGenCmd(context_);
  63. }
  64. }
  65. if (cmd)
  66. {
  67. if (cmd->Parse(arguments, i, errorMsg_))
  68. return cmd;
  69. break;
  70. }
  71. }
  72. return NULL;
  73. }
  74. }