allow zero-input (i.e. tone generator) processors to be added
[ardour2.git] / gtk2_ardour / opts.cc
blobca48e1cc3c2ed7a11cf0ddcf4a0df76ea52a45bd
1 /*
2 Copyright (C) 2001 Paul Davis
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.
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.
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.
20 #include <getopt.h>
21 #include <string.h>
22 #include <iostream>
23 #include <cstdlib>
25 #include "ardour/debug.h"
26 #include "ardour/session.h"
28 #include "opts.h"
30 #include "i18n.h"
32 using namespace std;
34 string ARDOUR_COMMAND_LINE::session_name = "";
35 string ARDOUR_COMMAND_LINE::jack_client_name = "ardour";
36 bool ARDOUR_COMMAND_LINE::show_key_actions = false;
37 bool ARDOUR_COMMAND_LINE::no_splash = true;
38 bool ARDOUR_COMMAND_LINE::just_version = false;
39 bool ARDOUR_COMMAND_LINE::use_vst = true;
40 bool ARDOUR_COMMAND_LINE::new_session = false;
41 char* ARDOUR_COMMAND_LINE::curvetest_file = 0;
42 bool ARDOUR_COMMAND_LINE::try_hw_optimization = true;
43 bool ARDOUR_COMMAND_LINE::no_connect_ports = false;
44 string ARDOUR_COMMAND_LINE::keybindings_path = ""; /* empty means use builtin default */
45 std::string ARDOUR_COMMAND_LINE::menus_file = "ardour.menus";
46 bool ARDOUR_COMMAND_LINE::finder_invoked_ardour = false;
47 string ARDOUR_COMMAND_LINE::immediate_save;
48 string ARDOUR_COMMAND_LINE::jack_session_uuid;
49 string ARDOUR_COMMAND_LINE::load_template;
51 using namespace ARDOUR_COMMAND_LINE;
53 int
54 print_help (const char *execname)
56 cout << _("Usage: ") << execname << " [OPTION]... [SESSION_NAME]\n\n"
57 << _(" [SESSION_NAME] Name of session to load\n")
58 << _(" -v, --version Show version information\n")
59 << _(" -h, --help Print this message\n")
60 << _(" -b, --bindings Print all possible keyboard binding names\n")
61 << _(" -c, --name <name> Use a specific jack client name, default is ardour\n")
62 << _(" -d, --disable-plugins Disable all plugins in an existing session\n")
63 << _(" -D, --debug <options> Set debug flags. Use \"-D list\" to see available options\n")
64 << _(" -n, --show-splash Show splash screen\n")
65 << _(" -m, --menus file Use \"file\" to define menus\n")
66 << _(" -N, --new session-name Create a new session from the command line\n")
67 << _(" -O, --no-hw-optimizations Disable h/w specific optimizations\n")
68 << _(" -S, --sync Draw the gui synchronously \n")
69 #ifdef VST_SUPPORT
70 << _(" -V, --novst Do not use VST support\n")
71 #endif
72 << _(" -E, --save <file> Load the specified session, save it to <file> and then quit\n")
73 << _(" -C, --curvetest filename Curve algorithm debugger\n")
74 << _(" -k, --keybindings filename Name of key bindings to load (default is ~/.ardour3/ardour.bindings)\n")
76 return 1;
80 int
81 ARDOUR_COMMAND_LINE::parse_opts (int argc, char *argv[])
83 const char *optstring = "bc:C:dD:hk:E:m:N:nOp:PST:U:vV";
84 const char *execname = strrchr (argv[0], '/');
86 if (getenv ("ARDOUR_SAE")) {
87 menus_file = "ardour-sae.menus";
88 keybindings_path = "SAE";
91 if (execname == 0) {
92 execname = argv[0];
93 } else {
94 execname++;
97 const struct option longopts[] = {
98 { "version", 0, 0, 'v' },
99 { "help", 0, 0, 'h' },
100 { "bindings", 0, 0, 'b' },
101 { "debug", 1, 0, 'D' },
102 { "show-splash", 0, 0, 'n' },
103 { "menus", 1, 0, 'm' },
104 { "name", 1, 0, 'c' },
105 { "novst", 0, 0, 'V' },
106 { "new", 1, 0, 'N' },
107 { "no-hw-optimizations", 0, 0, 'O' },
108 { "sync", 0, 0, 'S' },
109 { "curvetest", 1, 0, 'C' },
110 { "save", 1, 0, 'E' },
111 { "uuid", 1, 0, 'U' },
112 { "template", 1, 0, 'T' },
113 { "no-connect-ports", 0, 0, 'P' },
114 { 0, 0, 0, 0 }
117 int option_index = 0;
118 int c = 0;
120 while (1) {
121 c = getopt_long (argc, argv, optstring, longopts, &option_index);
123 if (c == -1) {
124 break;
127 switch (c) {
128 case 0:
129 break;
131 case 'v':
132 just_version = true;
133 break;
135 case 'h':
136 print_help (execname);
137 exit (0);
138 break;
139 case 'b':
140 show_key_actions = true;
141 break;
143 case 'd':
144 ARDOUR::Session::set_disable_all_loaded_plugins (true);
145 break;
147 case 'D':
148 if (PBD::parse_debug_options (optarg)) {
149 exit (0);
151 break;
153 case 'm':
154 menus_file = optarg;
155 break;
157 case 'n':
158 no_splash = false;
159 break;
161 case 'p':
162 //undocumented OS X finder -psn_XXXXX argument
163 finder_invoked_ardour = true;
164 break;
166 case 'S':
167 // ; just pass this through to gtk it will figure it out
168 break;
169 case 'T':
170 load_template = optarg;
171 break;
173 case 'N':
174 new_session = true;
175 session_name = optarg;
176 break;
178 case 'O':
179 try_hw_optimization = false;
180 break;
182 case 'P':
183 no_connect_ports = true;
184 break;
186 case 'V':
187 #ifdef VST_SUPPORT
188 use_vst = false;
189 #endif /* VST_SUPPORT */
190 break;
192 case 'c':
193 jack_client_name = optarg;
194 break;
196 case 'C':
197 curvetest_file = optarg;
198 break;
200 case 'k':
201 keybindings_path = optarg;
202 break;
204 case 'E':
205 immediate_save = optarg;
206 break;
208 case 'U':
209 jack_session_uuid = optarg;
210 break;
212 default:
213 return print_help(execname);
217 if (optind < argc) {
218 if (new_session) {
219 cerr << "Illogical combination: you can either create a new session, or a load an existing session but not both!" << endl;
220 return print_help(execname);
222 session_name = argv[optind++];
225 return 0;