7 #include "include/parser.h"
10 fprintf(stderr, "Usage: tmp [OPTION]... [FILE]\n");
11 fprintf(stderr, "A command-line based markdown presentation tool.\n\n");
12 fprintf(stderr, " -d, --debug enable debug messages on STDERR\n");
13 fprintf(stderr, " add it multiple times to increases debug level\n\n");
14 fprintf(stderr, " -h, --help display this help and exit\n");
15 fprintf(stderr, "\nWith no FILE, or when FILE is -, read standard input.\n\n");
19 int main(int argc, char *argv[]) {
21 // define command-line options
22 struct option longopts[] = {
23 { "debug", no_argument, 0, 'd' },
24 { "help", no_argument, 0, 'h' },
28 // parse command-line options
30 while ((opt = getopt_long(argc, argv, ":dh", longopts, NULL)) != -1) {
32 case 'd': debug += 1; break;
33 case 'h': usage(); break;
34 case ':': fprintf(stderr, "%s: '%c' requires an argument\n", argv[0], optopt); usage(); break;
36 default : fprintf(stderr, "%s: option '%c' is invalid\n", argv[0], optopt); usage(); break;
40 // open file or set input to STDIN
46 } while(++optind < argc);
48 if(!strcmp(file, "-")) {
51 input = fopen(file,"r");
53 fprintf(stderr, "%s: %s: %s\n", argv[0], file, strerror(errno));
61 // load deck object from input
63 doc = markdown_load(input);
68 markdown_debug(doc, debug);