Kylin/Universal/CommandLineInterpreter.h
2023-07-25 10:40:14 +08:00

24 lines
769 B
C++

#ifndef COMMANDLINEINTERPRETER_H
#define COMMANDLINEINTERPRETER_H
#include <boost/program_options/options_description.hpp>
#include <memory>
class CommandLineInterpreter {
public:
using DescriptionPointer = std::shared_ptr<boost::program_options::options_description>;
using DescriptionWeakPointer = std::weak_ptr<boost::program_options::options_description>;
CommandLineInterpreter(const DescriptionPointer &description, const std::string &prompt);
void interpret(std::istream &inputStream);
protected:
void handleReadLine(std::string line);
static std::vector<std::string> splitCommandLine(const std::string &input);
private:
const DescriptionWeakPointer m_description;
std::string m_prompt;
};
#endif // COMMANDLINEINTERPRETER_H