ardour
opts.cc
Go to the documentation of this file.
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 <string.h>
22 #include <iostream>
23 #include <cstdlib>
24 
25 #include "ardour/debug.h"
26 #include "ardour/session.h"
27 
28 #include "opts.h"
29 
30 #include "i18n.h"
31 
32 using namespace std;
33 
45 string ARDOUR_COMMAND_LINE::keybindings_path = ""; /* empty means use builtin default */
46 std::string ARDOUR_COMMAND_LINE::menus_file = "ardour.menus";
51 
52 using namespace ARDOUR_COMMAND_LINE;
53 
54 int
55 print_help (const char *execname)
56 {
57  cout << _("Usage: ") << execname << " [OPTION]... [SESSION_NAME]\n\n"
58  << _(" [SESSION_NAME] Name of session to load\n")
59  << _(" -v, --version Show version information\n")
60  << _(" -h, --help Print this message\n")
61  << _(" -a, --no-announcements Do not contact website for announcements\n")
62  << _(" -b, --bindings Print all possible keyboard binding names\n")
63  << _(" -c, --name <name> Use a specific backend client name, default is ardour\n")
64  << _(" -d, --disable-plugins Disable all plugins in an existing session\n")
65  << _(" -D, --debug <options> Set debug flags. Use \"-D list\" to see available options\n")
66  << _(" -n, --no-splash Do not show splash screen\n")
67  << _(" -m, --menus file Use \"file\" to define menus\n")
68  << _(" -N, --new session-name Create a new session from the command line\n")
69  << _(" -O, --no-hw-optimizations Disable h/w specific optimizations\n")
70  << _(" -P, --no-connect-ports Do not connect any ports at startup\n")
71  << _(" -S, --sync Draw the gui synchronously \n")
72 #ifdef WINDOWS_VST_SUPPORT
73  << _(" -V, --novst Do not use VST support\n")
74 #endif
75  << _(" -E, --save <file> Load the specified session, save it to <file> and then quit\n")
76  << _(" -C, --curvetest filename Curve algorithm debugger\n")
77  << _(" -k, --keybindings filename Name of key bindings to load (default is ~/.ardour3/ardour.bindings)\n")
78  ;
79  return 1;
80 
81 }
82 
83 int
84 ARDOUR_COMMAND_LINE::parse_opts (int argc, char *argv[])
85 {
86  const char *optstring = "abc:C:dD:hk:E:m:N:nOp:PST:U:vV";
87  const char *execname = strrchr (argv[0], '/');
88 
89  if (getenv ("ARDOUR_SAE")) {
90  menus_file = "ardour-sae.menus";
91  keybindings_path = "SAE";
92  }
93 
94  if (execname == 0) {
95  execname = argv[0];
96  } else {
97  execname++;
98  }
99 
100  const struct option longopts[] = {
101  { "version", 0, 0, 'v' },
102  { "help", 0, 0, 'h' },
103  { "no-announcements", 0, 0, 'a' },
104  { "bindings", 0, 0, 'b' },
105  { "disable-plugins", 0, 0, 'd' },
106  { "debug", 1, 0, 'D' },
107  { "no-splash", 0, 0, 'n' },
108  { "menus", 1, 0, 'm' },
109  { "name", 1, 0, 'c' },
110  { "novst", 0, 0, 'V' },
111  { "new", 1, 0, 'N' },
112  { "no-hw-optimizations", 0, 0, 'O' },
113  { "sync", 0, 0, 'S' },
114  { "curvetest", 1, 0, 'C' },
115  { "save", 1, 0, 'E' },
116  { "uuid", 1, 0, 'U' },
117  { "template", 1, 0, 'T' },
118  { "no-connect-ports", 0, 0, 'P' },
119  { 0, 0, 0, 0 }
120  };
121 
122  int option_index = 0;
123  int c = 0;
124 
125  while (1) {
126  c = getopt_long (argc, argv, optstring, longopts, &option_index);
127 
128  if (c == -1) {
129  break;
130  }
131 
132  switch (c) {
133  case 0:
134  break;
135 
136  case 'v':
137  just_version = true;
138  break;
139 
140  case 'h':
141  print_help (execname);
142  exit (0);
143  break;
144  case 'a':
145  check_announcements = false;
146  break;
147 
148  case 'b':
149  show_key_actions = true;
150  break;
151 
152  case 'd':
154  break;
155 
156  case 'D':
158  exit (0);
159  }
160  break;
161 
162  case 'm':
163  menus_file = optarg;
164  break;
165 
166  case 'n':
167  no_splash = true;
168  break;
169 
170  case 'p':
171  //undocumented OS X finder -psn_XXXXX argument
172  finder_invoked_ardour = true;
173  break;
174 
175  case 'S':
176  // ; just pass this through to gtk it will figure it out
177  break;
178  case 'T':
180  break;
181 
182  case 'N':
183  new_session = true;
185  break;
186 
187  case 'O':
188  try_hw_optimization = false;
189  break;
190 
191  case 'P':
192  no_connect_ports = true;
193  break;
194 
195  case 'V':
196 #ifdef WINDOWS_VST_SUPPORT
197  use_vst = false;
198 #endif /* WINDOWS_VST_SUPPORT */
199  break;
200 
201  case 'c':
203  break;
204 
205  case 'C':
207  break;
208 
209  case 'k':
211  break;
212 
213  case 'E':
215  break;
216 
217  case 'U':
219  break;
220 
221  default:
222  return print_help(execname);
223  }
224  }
225 
226  if (optind < argc) {
227  if (new_session) {
228  cerr << "Illogical combination: you can either create a new session, or a load an existing session but not both!" << endl;
229  return print_help(execname);
230  }
231  session_name = argv[optind++];
232  }
233 
234  return 0;
235 }
236 
int32_t parse_opts(int argc, char *argv[])
Definition: opts.cc:84
bool try_hw_optimization
Definition: opts.cc:43
std::string menus_file
Definition: opts.cc:46
static void set_disable_all_loaded_plugins(bool yn)
Definition: session.h:728
Definition: Beats.hpp:239
bool finder_invoked_ardour
Definition: opts.cc:47
bool no_connect_ports
Definition: opts.cc:44
int print_help(const char *execname)
Definition: opts.cc:55
#define _(Text)
Definition: i18n.h:11
Definition: getopt.h:74
bool check_announcements
Definition: opts.cc:50
bool just_version
Definition: opts.cc:39
std::string backend_session_uuid
Definition: opts.cc:36
__BEGIN_DECLS GETOPT_API int getopt_long(int nargc, char *const *nargv, const char *options, const struct option *long_options, int *idx)
Definition: getopt_long.c:395
std::string load_template
Definition: opts.cc:49
std::string keybindings_path
Definition: opts.cc:45
bool new_session
Definition: opts.cc:41
char * curvetest_file
Definition: opts.cc:42
bool show_key_actions
Definition: opts.cc:37
std::string backend_client_name
Definition: opts.cc:35
std::string session_name
Definition: opts.cc:34
GETOPT_API char * optarg
Definition: getopt.c:52
std::string immediate_save
Definition: opts.cc:48
GETOPT_API int optind
Definition: getopt.c:49
LIBPBD_API int parse_debug_options(const char *str)
Definition: debug.cc:80