Newer
Older
#pragma once
#include <Arduino.h>
#include "syringe.h"
class Cli
{
private:
Syringe& syringe;
String _currentInput;
String _temp;
int _currentWordIndex;
void resetNextWord ();
const char* findNextWord ();
void copyNextToTemp ();
bool kw (const __FlashStringHelper* keyWord, const char* input);
bool kw (const __FlashStringHelper* keyWord);
void syntax (const __FlashStringHelper* cmd);
void syntax (const char* cmd = nullptr);
void answer (bool ok, const String& error_message = emptyString) const;
public:
Cli (Syringe& syringe, int bufferLen = 32): syringe(syringe)
{
_currentInput.reserve(bufferLen);
_temp.reserve(bufferLen);
resetNextWord();
}
void loop (Stream& input);
};