storybook/src/cli/storybook_cli.cpp

33 lines
513 B
C++

#include <cstdio>
#include <cstdlib>
#include "../base/storybook.h"
void usage(const char* bin) {
fprintf(stderr, "Usage: %s <storyfile>", bin);
exit(1);
}
int main(int argc, const char *argv[]) {
if (argc != 2) {
usage(argv[0]);
}
FILE *fin = fopen(argv[1], "r");
if (!fin) {
fprintf(stderr, "Error: could not read %s", argv[1]);
return 2;
}
storybook::Storybook sb(fin);
fclose(fin);
sb.Find("START");
sb.Play();
while (!sb.IsEnded) {
sb.Play();
}
return 0;
}