]> git.donarmstrong.com Git - lilypond.git/blob - src/main.cc
release: 0.0.17
[lilypond.git] / src / main.cc
1 #include <iostream.h>
2 #include <assert.h>
3 #include "lgetopt.hh"
4 #include "misc.hh"
5 #include "string.hh"
6 #include "main.hh"
7
8 extern void parse_file(String s);
9
10 long_option_init theopts[] = {
11     1, "output", 'o',
12     0, "warranty", 'w',
13     0, "help", 'h',
14     0, "debug", 'd',
15     0,0,0
16 };
17
18 void
19 help()
20 {
21     cout <<
22         "--help, -h             This help\n"
23         "--warranty, -w         show warranty & copyright\n"
24         "--output, -o           set default output\n"
25         "--debug, -d            enable debug output\n"
26         ;
27     
28 }
29 void notice()
30 {
31     cout <<
32         "\n"
33         "LilyPond, a music typesetter.\n"
34         "Copyright (C) 1996 by\n"
35         "  Han-Wen Nienhuys <hanwen@stack.nl>\n"
36         "  Jan-Nieuwenhuizen <jan@digicash.com>\n"
37         "\n"
38         "    This program is free software; you can redistribute it and/or\n"
39         "modify it under the terms of the GNU General Public License version 2\n"
40         "as published by the Free Software Foundation.\n"
41         "\n"
42         "    This program is distributed in the hope that it will be useful,\n"
43         "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
44         "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n"
45         "General Public License for more details.\n"
46         "\n"
47         "    You should have received a copy (refer to the file COPYING) of the\n"
48         "GNU General Public License along with this program; if not, write to\n"
49         "the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,\n"
50         "USA.\n";
51 }
52
53 int
54 main (int argc, char **argv)
55 {
56     Getopt_long oparser(argc, argv,theopts);
57     debug_init();
58     cout << get_version();
59     
60     while (long_option_init * opt = oparser()) {
61         switch ( opt->shortname){
62         case 'o':
63             set_default_output(oparser.optarg);
64             break;
65         case 'w':
66             notice();
67             exit(0);
68             break;
69         case 'h':
70             help();
71             exit(0);
72             break;
73         case 'd':
74             set_debug(true);
75             break;
76         default:
77             assert(false);
78             break;
79         }
80     }
81
82     int p=0;
83     char *arg ;
84     while ( (arg= oparser.get_next_arg()) ) {
85         parse_file(arg);        
86         do_scores();
87         p++;
88     }
89     if (!p) {
90         parse_file(""); 
91         do_scores();
92     }
93         
94     exit (0);
95 }