engine dialog work, new -m option for menu file selection, new obolean automation...
[ardour.git] / gtk2_ardour / opts.cc
1 /*
2     Copyright (C) 2001 Paul Davis
3     
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include <getopt.h>
21 #include <iostream>
22 #include <cstdlib>
23
24 #include "opts.h"
25
26 #include "i18n.h"
27
28 using namespace std;
29
30 string GTK_ARDOUR::session_name = "";
31 string GTK_ARDOUR::jack_client_name = "ardour";
32 bool  GTK_ARDOUR::show_key_actions = false;
33 bool GTK_ARDOUR::no_splash = true;
34 bool GTK_ARDOUR::just_version = false;
35 bool GTK_ARDOUR::use_vst = true;
36 bool GTK_ARDOUR::new_session = false;
37 char* GTK_ARDOUR::curvetest_file = 0;
38 bool GTK_ARDOUR::try_hw_optimization = true;
39 string GTK_ARDOUR::keybindings_path = ""; /* empty means use builtin default */
40 string GTK_ARDOUR::menus_file = "ardour.menus";
41
42 using namespace GTK_ARDOUR;
43
44 int
45 print_help (const char *execname)
46 {
47         cout << _("Usage: ") << execname << "\n"
48              << _("  -v, --version                    Show version information\n")
49              << _("  -h, --help                       Print this message\n")
50              << _("  -b, --bindings                   Print all possible keyboard binding names\n")
51              << _("  -n, --show-splash                Show splash screen\n")
52              << _("  -c, --name  name                 Use a specific jack client name, default is ardour\n")
53              << _("  -m, --menus file                 Use \"file\" for Ardour menus\n")                       
54              << _("  -N, --new session-name           Create a new session from the command line\n")
55              << _("  -O, --no-hw-optimizations        Disable h/w specific optimizations\n")
56              << _("  -S, --sync                       Draw the gui synchronously \n")
57 #ifdef VST_SUPPORT
58              << _("  -V, --novst                      Do not use VST support\n")
59 #endif
60              << _("  [session-name]                   Name of session to load\n")
61              << _("  -C, --curvetest filename         Curve algorithm debugger\n")
62              << _("  -k, --keybindings filename       Name of key bindings to load (default is ~/.ardour2/ardour.bindings)\n")
63                 ;
64         return 1;
65
66 }
67
68 int
69 GTK_ARDOUR::parse_opts (int argc, char *argv[])
70 {
71         const char *optstring = "U:hSbvVnOc:C:m:N:k:";
72         const char *execname = strrchr (argv[0], '/');
73
74         if (execname == 0) {
75                 execname = argv[0];
76         } else {
77                 execname++;
78         }
79
80         const struct option longopts[] = {
81                 { "version", 0, 0, 'v' },
82                 { "help", 0, 0, 'h' },
83                 { "bindings", 0, 0, 'b' },
84                 { "show-splash", 0, 0, 'n' },
85                 { "menus", 1, 0, 'm'} ,
86                 { "name", 1, 0, 'c' },
87                 { "novst", 0, 0, 'V' },
88                 { "new", 1, 0, 'N' },
89                 { "no-hw-optimizations", 0, 0, 'O' },
90                 { "sync", 0, 0, 'O' },
91                 { "curvetest", 1, 0, 'C' },
92                 { 0, 0, 0, 0 }
93         };
94
95         int option_index = 0;
96         int c = 0;
97
98         while (1) {
99                 c = getopt_long (argc, argv, optstring, longopts, &option_index);
100
101                 if (c == -1) {
102                         break;
103                 }
104
105                 switch (c) {
106                 case 0:
107                         break;
108                 
109                 case 'v':
110                         just_version = true;
111                         break;
112
113                 case 'h':
114                         print_help (execname);
115                         exit (0);
116                         break;
117
118                 case 'b':
119                         show_key_actions = true;
120                         break;
121
122                 case 'm':
123                         menus_file = optarg;
124                         break;
125
126                 case 'n':
127                         no_splash = false;
128                         break;
129                 
130                 case 'S':
131                 //      ; just pass this through to gtk it will figure it out
132                         break;
133
134                 case 'N':
135                         new_session = true;
136                         session_name = optarg;
137                         break;
138
139                 case 'O':
140                         try_hw_optimization = false;
141                         break;
142
143                 case 'V':
144 #ifdef VST_SUPPORT
145                         use_vst = false;
146 #endif /* VST_SUPPORT */
147                         break;
148
149                 case 'c':
150                         jack_client_name = optarg;
151                         break;
152
153                 case 'C':
154                         curvetest_file = optarg;
155                         break;
156
157                 case 'k':
158                         keybindings_path = optarg;
159                         break;
160
161                 default:
162                         return print_help(execname);
163                 }
164         }
165
166         if (optind < argc) {
167                 if (new_session) {
168                         cerr << "Illogical combination: you can either create a new session, or a load an existing session but not both!" << endl;
169                         return print_help(execname);
170                 }
171                 session_name = argv[optind++];
172         }
173
174
175         return 0;
176 }
177