CommandLine.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //
  2. // Created by xcbosa on 2023/1/31.
  3. //
  4. #pragma once
  5. #include "utils-private.h"
  6. namespace xc {
  7. namespace utils {
  8. class CommandLineWorker;
  9. class CommandLineCommand {
  10. friend CommandLineWorker;
  11. public:
  12. CommandLineCommand(string name, string usage, string message);
  13. virtual void evaluate(string userInputLine) const = 0;
  14. protected:
  15. string commandName;
  16. string commandUsage;
  17. string message;
  18. };
  19. class CommandLineStringCommand: public CommandLineCommand{
  20. public:
  21. CommandLineStringCommand(string commandName, string commandUsage, string message, int argCnt, function<void (vector<string>)> handler);
  22. void evaluate(string userInputLine) const override;
  23. private:
  24. int argCnt;
  25. function<void (vector<string>)> handler;
  26. };
  27. typedef CommandLineStringCommand strcmd;
  28. class CommandLineWorker {
  29. public:
  30. void workerLoop();
  31. };
  32. } // xc
  33. } // utils