File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed
Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change 3232
3333#include < cstdlib>
3434#include < future>
35+ #include < unistd.h>
3536
3637int main (int argc, char ** argv)
3738{
@@ -121,7 +122,36 @@ int main(int argc, char** argv)
121122 interfaces.emplace_back (std::make_unique<StatsDemo>());
122123 interfaces.emplace_back (std::make_unique<TextToSpeechDemo>());
123124
124- if (appConfig.autoRun )
125+ if (!isatty (fileno (stdin)))
126+ {
127+ appConfig.autoRun = true ;
128+ std::string line;
129+ while (std::getline (std::cin, line))
130+ {
131+ bool found = false ;
132+ for (const auto & interface : interfaces)
133+ {
134+ for (const auto & method : interface->methods ())
135+ {
136+ if (method == line)
137+ {
138+ interface->runOption (method);
139+ found = true ;
140+ break ;
141+ }
142+ }
143+ if (found)
144+ {
145+ break ;
146+ }
147+ }
148+ if (!found)
149+ {
150+ std::cout << " Method not found: " << line << std::endl;
151+ }
152+ }
153+ }
154+ else if (appConfig.autoRun )
125155 {
126156 for (auto & interface : interfaces)
127157 {
Original file line number Diff line number Diff line change 1+ Accessibility.highContrastUI
2+ Device.chipsetId
3+ TextToSpeech.speak
4+ TextToSpeech.listVoices
5+ TextToSpeech.pause
You can’t perform that action at this time.
0 commit comments