7 #include "include/mdp.h"
10 fprintf(stderr, "%s", "Usage: mdp [OPTION]... [FILE]\n");
11 fprintf(stderr, "%s", "A command-line based markdown presentation tool.\n\n");
12 fprintf(stderr, "%s", " -d, --debug enable debug messages on STDERR\n");
13 fprintf(stderr, "%s", " add it multiple times to increases debug level\n\n");
14 fprintf(stderr, "%s", " -h, --help display this help and exit\n");
15 fprintf(stderr, "%s", "\nWith no FILE, or when FILE is -, read standard input.\n\n");
20 printf("mdp %d.%d\n", MAJOR_VERSION, MINOR_VERSION);
21 //TODO add copyright, license, written by
25 int main(int argc, char *argv[]) {
27 // define command-line options
28 struct option longopts[] = {
29 { "debug", no_argument, 0, 'd' },
30 { "help", no_argument, 0, 'h' },
31 { "version", no_argument, 0, 'v' },
35 // parse command-line options
37 while ((opt = getopt_long(argc, argv, ":dhv", longopts, NULL)) != -1) {
39 case 'd': debug += 1; break;
40 case 'h': usage(); break;
41 case 'v': version(); break;
42 case ':': fprintf(stderr, "%s: '%c' requires an argument\n", argv[0], optopt); usage(); break;
44 default : fprintf(stderr, "%s: option '%c' is invalid\n", argv[0], optopt); usage(); break;
48 // open file or set input to STDIN
54 } while(++optind < argc);
56 if(!strcmp(file, "-")) {
59 input = fopen(file,"r");
61 fprintf(stderr, "%s: %s: %s\n", argv[0], file, strerror(errno));
69 // load deck object from input
71 deck = markdown_load(input);
76 markdown_debug(deck, debug);
79 ncurses_display(deck, 0, 0);