diff --git a/src/clirecorder.cpp b/src/clirecorder.cpp index 59e3736..edaff98 100644 --- a/src/clirecorder.cpp +++ b/src/clirecorder.cpp @@ -1,18 +1,27 @@ #include "recording.h" -#include "xdfwriter.h" + +void print_usage(char* name) { + std::cout << "Usage: " << name << " outputfile.xdf 'searchstr' ['searchstr2' ...]\n\n" + << "searchstr can be anything accepted by lsl_resolve_bypred\n"; + std::cout << "Keep in mind that your shell might remove quotes\n"; + std::cout << "Examples:\n\t" << name << " foo.xdf type='EEG' "; + std::cout << " \"host='LabPC1' or host='LabPC2' and starts-with(name,'MyShinySensor')\"\n\t"; + std::cout << name << " foo.xdf \"name='Tobii' and type='Eyetracker'\"\n"; +} + int main(int argc, char **argv) { if (argc < 3 || (argc == 2 && std::string(argv[1]) == "-h")) { - std::cout << "Usage: " << argv[0] << " outputfile.xdf 'searchstr' ['searchstr2' ...]\n\n" - << "searchstr can be anything accepted by lsl_resolve_bypred\n"; - std::cout << "Keep in mind that your shell might remove quotes\n"; - std::cout << "Examples:\n\t" << argv[0] << " foo.xdf 'type=\"EEG\"' "; - std::cout << " 'host=\"LabPC1\" or host=\"LabPC2\"'\n\t"; - std::cout << argv[0] << " foo.xdf'name=\"Tobii and type=\"Eyetracker\"'\n"; + print_usage(argv[0]); return 1; } std::vector infos = lsl::resolve_streams(), recordstreams; + std::vector watchfor; + + for (const auto &info : infos) { + std::cout << "Available: " << info.name() << '@' << info.hostname() << std::endl; + } for (int i = 2; i < argc; ++i) { bool matched = false; @@ -25,15 +34,14 @@ int main(int argc, char **argv) { } } if (!matched) { - std::cout << '"' << argv[i] << "\" matched no stream!\n"; - return 2; + std::cout << '"' << argv[i] << "\" matched no stream, will keep watching\n"; + watchfor.emplace_back(argv[i]); } } - std::vector watchfor; std::map sync_options; - std::cout << "Starting the recording, press Enter to quit" << std::endl; + std::cout << "Starting the recording" << std::endl; recording r(argv[1], recordstreams, watchfor, sync_options, true); - std::cin.get(); - return 0; + + while (true) std::this_thread::yield(); }