Python: Give goto_url_hook only one argument, like follow_url_hook.
[elinks.git] / src / config / cmdline.c
blob179883ae0861824a0368d6fadf9156ae13e8b573
1 /* Command line processing */
3 #ifdef HAVE_CONFIG_H
4 #include "config.h"
5 #endif
7 #include <stdio.h>
8 #include <string.h>
9 #include <sys/types.h>
10 #ifdef HAVE_SYS_SOCKET_H
11 #include <sys/socket.h> /* OS/2 needs this after sys/types.h */
12 #endif
13 #include <sys/stat.h> /* OS/2 needs this after sys/types.h */
14 #ifdef HAVE_NETDB_H
15 #include <netdb.h>
16 #endif
18 /* We need to have it here. Stupid BSD. */
19 #ifdef HAVE_NETINET_IN_H
20 #include <netinet/in.h>
21 #endif
22 #ifdef HAVE_ARPA_INET_H
23 #include <arpa/inet.h>
24 #endif
26 #include "elinks.h"
28 #include "config/cmdline.h"
29 #include "config/conf.h"
30 #include "config/options.h"
31 #include "config/opttypes.h"
32 #include "intl/gettext/libintl.h"
33 #include "network/dns.h"
34 #include "protocol/uri.h"
35 #include "session/session.h"
36 #include "util/error.h"
37 #include "util/file.h"
38 #include "util/lists.h"
39 #include "util/memory.h"
40 #include "util/string.h"
43 /* Hack to handle URL extraction for -remote commands */
44 static unsigned char *remote_url;
46 static enum retval
47 parse_options_(int argc, unsigned char *argv[], struct option *opt,
48 struct list_head *url_list)
50 while (argc) {
51 argv++, argc--;
53 if (argv[-1][0] == '-' && argv[-1][1]) {
54 struct option *option;
55 unsigned char *argname = &argv[-1][1];
56 unsigned char *oname = stracpy(argname);
57 unsigned char *err;
59 if (!oname) continue;
61 /* Treat --foo same as -foo. */
62 if (argname[0] == '-') argname++;
64 option = get_opt_rec(opt, argname);
65 if (!option) option = get_opt_rec(opt, oname);
66 if (!option) {
67 unsigned char *pos;
69 oname++; /* the '-' */
70 /* Substitute '-' by '_'. This helps
71 * compatibility with that very wicked browser
72 * called 'lynx'. */
73 for (pos = strchr(oname, '_'); pos;
74 pos = strchr(pos, '_'))
75 *pos = '-';
76 option = get_opt_rec(opt, oname);
77 oname--;
80 mem_free(oname);
82 if (!option) goto unknown_option;
84 if (!option_types[option->type].cmdline)
85 goto unknown_option;
87 err = option_types[option->type].cmdline(option, &argv, &argc);
89 if (err) {
90 if (err[0]) {
91 usrerror(gettext("Cannot parse option %s: %s"), argv[-1], err);
93 return RET_SYNTAX;
96 /* XXX: Empty strings means all is well and have
97 * a cup of shut the fsck up. */
98 return RET_COMMAND;
100 } else if (remote_url) {
101 if (url_list) add_to_string_list(url_list, remote_url, -1);
102 mem_free(remote_url);
103 remote_url = NULL;
106 } else if (url_list) {
107 add_to_string_list(url_list, argv[-1], -1);
111 return RET_OK;
113 unknown_option:
114 usrerror(gettext("Unknown option %s"), argv[-1]);
115 return RET_SYNTAX;
118 enum retval
119 parse_options(int argc, unsigned char *argv[], struct list_head *url_list)
121 return parse_options_(argc, argv, cmdline_options, url_list);
125 /**********************************************************************
126 Options handlers
127 **********************************************************************/
129 static unsigned char *
130 eval_cmd(struct option *o, unsigned char ***argv, int *argc)
132 if (*argc < 1) return gettext("Parameter expected");
134 (*argv)++; (*argc)--; /* Consume next argument */
136 parse_config_file(config_options, "-eval", *(*argv - 1), NULL, 0);
138 fflush(stdout);
140 return NULL;
143 static unsigned char *
144 forcehtml_cmd(struct option *o, unsigned char ***argv, int *argc)
146 safe_strncpy(get_opt_str("mime.default_type"), "text/html", MAX_STR_LEN);
147 return NULL;
150 static unsigned char *
151 lookup_cmd(struct option *o, unsigned char ***argv, int *argc)
153 struct sockaddr_storage *addrs = NULL;
154 int addrno, i;
156 if (!*argc) return gettext("Parameter expected");
157 if (*argc > 1) return gettext("Too many parameters");
159 (*argv)++; (*argc)--;
160 if (do_real_lookup(*(*argv - 1), &addrs, &addrno, 0) == DNS_ERROR) {
161 #ifdef HAVE_HERROR
162 herror(gettext("error"));
163 #else
164 usrerror(gettext("Host not found"));
165 #endif
166 return "";
169 for (i = 0; i < addrno; i++) {
170 #ifdef CONFIG_IPV6
171 struct sockaddr_in6 addr = *((struct sockaddr_in6 *) &(addrs)[i]);
172 unsigned char p[INET6_ADDRSTRLEN];
174 if (! inet_ntop(addr.sin6_family,
175 (addr.sin6_family == AF_INET6 ? (void *) &addr.sin6_addr
176 : (void *) &((struct sockaddr_in *) &addr)->sin_addr),
177 p, INET6_ADDRSTRLEN))
178 ERROR(gettext("Resolver error"));
179 else
180 printf("%s\n", p);
181 #else
182 struct sockaddr_in addr = *((struct sockaddr_in *) &(addrs)[i]);
183 unsigned char *p = (unsigned char *) &addr.sin_addr.s_addr;
185 printf("%d.%d.%d.%d\n", (int) p[0], (int) p[1],
186 (int) p[2], (int) p[3]);
187 #endif
190 mem_free_if(addrs);
192 fflush(stdout);
194 return "";
197 #define skipback_whitespace(start, S) \
198 while ((start) < (S) && isspace((S)[-1])) (S)--;
200 static unsigned char *
201 remote_cmd(struct option *o, unsigned char ***argv, int *argc)
203 struct {
204 unsigned char *name;
205 enum {
206 REMOTE_METHOD_OPENURL,
207 REMOTE_METHOD_PING,
208 REMOTE_METHOD_XFEDOCOMMAND,
209 REMOTE_METHOD_ADDBOOKMARK,
210 REMOTE_METHOD_INFOBOX,
211 REMOTE_METHOD_NOT_SUPPORTED,
212 } type;
213 } remote_methods[] = {
214 { "openURL", REMOTE_METHOD_OPENURL },
215 { "ping", REMOTE_METHOD_PING },
216 { "addBookmark", REMOTE_METHOD_ADDBOOKMARK },
217 { "infoBox", REMOTE_METHOD_INFOBOX },
218 { "xfeDoCommand", REMOTE_METHOD_XFEDOCOMMAND },
219 { NULL, REMOTE_METHOD_NOT_SUPPORTED },
221 unsigned char *command, *arg, *argend, *argstring;
222 int method, len = 0;
223 unsigned char *remote_argv[10];
224 int remote_argc;
226 if (*argc < 1) return gettext("Parameter expected");
228 command = *(*argv);
230 while (isasciialpha(command[len]))
231 len++;
233 /* Find the begining and end of the argument list. */
235 arg = command + len;
236 skip_space(arg);
238 argend = arg + strlen(arg);
239 skipback_whitespace(arg, argend);
240 if (argend > arg)
241 argend--;
243 /* Decide whether to use the "extended" --remote format where
244 * all URLs following should be opened in tabs. */
245 if (len == 0 || *arg != '(' || *argend != ')') {
246 /* Just open any passed URLs in new tabs */
247 remote_session_flags |= SES_REMOTE_NEW_TAB;
248 return NULL;
251 arg++;
253 arg = argstring = memacpy(arg, argend - arg);
254 if (!argstring)
255 return gettext("Out of memory");
257 remote_argc = 0;
258 do {
259 unsigned char *start, *end;
261 if (remote_argc > sizeof_array(remote_argv)) {
262 mem_free(argstring);
263 return gettext("Too many arguments");
266 /* Skip parenthesis, comma, and surrounding whitespace. */
267 skip_space(arg);
268 start = arg;
270 if (*start == '"') {
271 end = ++start;
272 while ((end = strchr(end, '"'))) {
273 /* Treat "" inside quoted arg as ". */
274 if (end[1] != '"')
275 break;
277 end += 2;
280 if (!end)
281 return gettext("Mismatched ending argument quoting");
283 arg = end + 1;
284 skip_space(arg);
285 if (*arg && *arg != ',')
286 return gettext("Garbage after quoted argument");
288 remote_argv[remote_argc++] = start;
289 *end = 0;
291 /* Unescape "" to ". */
292 for (end = start; *end; start++, end++) {
293 *start = *end;
294 if (*end == '"')
295 end++;
297 *start = 0;
299 } else {
300 end = strchr(start, ',');
301 if (!end)
302 end = start + strlen(start);
303 arg = end;
304 skipback_whitespace(start, end);
306 if (start != end)
307 remote_argv[remote_argc++] = start;
308 *end = 0;
311 if (*arg == ',')
312 arg++;
313 } while (*arg);
315 for (method = 0; remote_methods[method].name; method++) {
316 unsigned char *name = remote_methods[method].name;
318 if (!strlcasecmp(command, len, name, -1))
319 break;
322 switch (remote_methods[method].type) {
323 case REMOTE_METHOD_OPENURL:
324 if (remote_argc < 1) {
325 /* Prompt for a URL with a dialog box */
326 remote_session_flags |= SES_REMOTE_PROMPT_URL;
327 break;
330 if (remote_argc == 2) {
331 unsigned char *where = remote_argv[1];
333 if (strstr(where, "new-window")) {
334 remote_session_flags |= SES_REMOTE_NEW_WINDOW;
336 } else if (strstr(where, "new-tab")) {
337 remote_session_flags |= SES_REMOTE_NEW_TAB;
339 } else {
340 /* Bail out when getting unknown parameter */
341 /* TODO: new-screen */
342 break;
345 } else {
346 remote_session_flags |= SES_REMOTE_CURRENT_TAB;
349 remote_url = stracpy(remote_argv[0]);
350 break;
352 case REMOTE_METHOD_XFEDOCOMMAND:
353 if (remote_argc < 1)
354 break;
356 if (!strcasecmp(remote_argv[0], "openBrowser")) {
357 remote_session_flags = SES_REMOTE_NEW_WINDOW;
359 break;
361 case REMOTE_METHOD_PING:
362 remote_session_flags = SES_REMOTE_PING;
363 break;
365 case REMOTE_METHOD_ADDBOOKMARK:
366 if (remote_argc < 1)
367 break;
368 remote_url = stracpy(remote_argv[0]);
369 remote_session_flags = SES_REMOTE_ADD_BOOKMARK;
370 break;
372 case REMOTE_METHOD_INFOBOX:
373 if (remote_argc < 1)
374 break;
375 remote_url = stracpy(remote_argv[0]);
376 if (remote_url)
377 insert_in_string(&remote_url, 0, "about:", 6);
378 remote_session_flags = SES_REMOTE_INFO_BOX;
379 break;
381 case REMOTE_METHOD_NOT_SUPPORTED:
382 break;
385 mem_free(argstring);
387 /* If no flags was applied it can only mean we are dealing with
388 * unknown method. */
389 if (!remote_session_flags)
390 return gettext("Remote method not supported");
392 (*argv)++; (*argc)--; /* Consume next argument */
394 return NULL;
397 static unsigned char *
398 version_cmd(struct option *o, unsigned char ***argv, int *argc)
400 printf("%s\n", full_static_version);
401 fflush(stdout);
402 return "";
406 /* Below we handle help usage printing.
408 * We're trying to achieve several goals here:
410 * - Genericly define a function to print option trees iteratively.
411 * - Make output parsable for various doc tools (to make manpages).
412 * - Do some non generic fancy stuff like printing semi-aliased
413 * options (like: -?, -h and -help) on one line when printing
414 * short help. */
416 #define gettext_nonempty(x) (*(x) ? gettext(x) : (x))
418 static void
419 print_full_help(struct option *tree, unsigned char *path)
421 struct option *option;
422 unsigned char saved[MAX_STR_LEN];
423 unsigned char *savedpos = saved;
425 *savedpos = 0;
427 foreach (option, *tree->value.tree) {
428 enum option_type type = option->type;
429 unsigned char *help;
430 unsigned char *capt = option->capt;
431 unsigned char *desc = (option->desc && *option->desc)
432 ? (unsigned char *) gettext(option->desc)
433 : (unsigned char *) "N/A";
435 /* Don't print deprecated aliases (if we don't walk command
436 * line options which use aliases for legitimate options). */
437 if ((type == OPT_ALIAS && tree != cmdline_options)
438 || (option->flags & OPT_HIDDEN))
439 continue;
441 if (!capt && !strncasecmp(option->name, "_template_", 10))
442 capt = (unsigned char *) N_("Template option folder");
444 if (!capt) {
445 int len = strlen(option->name);
446 int max = MAX_STR_LEN - (savedpos - saved);
448 safe_strncpy(savedpos, option->name, max);
449 safe_strncpy(savedpos + len, ", -", max - len);
450 savedpos += len + 3;
451 continue;
454 help = gettext_nonempty(option_types[option->type].help_str);
456 if (type != OPT_TREE)
457 printf(" %s%s%s %s ",
458 path, saved, option->name, help);
460 /* Print the 'title' of each option type. */
461 switch (type) {
462 case OPT_BOOL:
463 case OPT_INT:
464 case OPT_LONG:
465 printf(gettext("(default: %ld)"),
466 type == OPT_LONG
467 ? option->value.big_number
468 : (long) option->value.number);
469 break;
471 case OPT_STRING:
472 printf(gettext("(default: \"%s\")"),
473 option->value.string);
474 break;
476 case OPT_ALIAS:
477 printf(gettext("(alias for %s)"),
478 option->value.string);
479 break;
481 case OPT_CODEPAGE:
482 printf(gettext("(default: %s)"),
483 get_cp_name(option->value.number));
484 break;
486 case OPT_COLOR:
488 color_T color = option->value.color;
489 unsigned char hexcolor[8];
491 printf(gettext("(default: %s)"),
492 get_color_string(color, hexcolor));
493 break;
496 case OPT_COMMAND:
497 break;
499 case OPT_LANGUAGE:
500 #ifdef CONFIG_NLS
501 printf(gettext("(default: \"%s\")"),
502 language_to_name(option->value.number));
503 #endif
504 break;
506 case OPT_TREE:
508 int pathlen = strlen(path);
509 int namelen = strlen(option->name);
511 if (pathlen + namelen + 2 > MAX_STR_LEN)
512 continue;
514 /* Append option name to path */
515 if (pathlen > 0) {
516 memcpy(saved, path, pathlen);
517 savedpos = saved + pathlen;
518 } else {
519 savedpos = saved;
521 memcpy(savedpos, option->name, namelen + 1);
522 savedpos += namelen;
524 capt = gettext_nonempty(capt);
525 printf(" %s: (%s)", capt, saved);
526 break;
530 printf("\n %8s", "");
532 int l = strlen(desc);
533 int i;
535 for (i = 0; i < l; i++) {
536 putchar(desc[i]);
538 if (desc[i] == '\n')
539 printf(" %8s", "");
542 printf("\n\n");
544 if (option->type == OPT_TREE) {
545 memcpy(savedpos, ".", 2);
546 print_full_help(option, saved);
549 savedpos = saved;
550 *savedpos = 0;
554 static void
555 print_short_help(void)
557 #define ALIGN_WIDTH 20
558 struct option *option;
559 struct string string = NULL_STRING;
560 struct string *saved = NULL;
561 unsigned char align[ALIGN_WIDTH];
563 /* Initialize @space used to align captions. */
564 memset(align, ' ', sizeof(align) - 1);
565 align[sizeof(align) - 1] = 0;
567 foreach (option, *cmdline_options->value.tree) {
568 unsigned char *capt;
569 unsigned char *help;
570 unsigned char *info = saved ? saved->source
571 : (unsigned char *) "";
572 int len = strlen(option->name);
574 /* Avoid printing compatibility options */
575 if (option->flags & OPT_HIDDEN)
576 continue;
578 /* When no caption is available the option name is 'stacked'
579 * and the caption is shared with next options that has one. */
580 if (!option->capt) {
581 if (!saved) {
582 if (!init_string(&string))
583 continue;
585 saved = &string;
588 add_to_string(saved, option->name);
589 add_to_string(saved, ", -");
590 continue;
593 capt = gettext_nonempty(option->capt);
594 help = gettext_nonempty(option_types[option->type].help_str);
596 /* When @help string is non empty align at least one space. */
597 len = ALIGN_WIDTH - len - strlen(help);
598 len -= (saved ? saved->length : 0);
599 len = (len < 0) ? !!(*help) : len;
601 align[len] = '\0';
602 printf(" -%s%s %s%s%s\n",
603 info, option->name, help, align, capt);
604 align[len] = ' ';
605 if (saved) {
606 done_string(saved);
607 saved = NULL;
610 #undef ALIGN_WIDTH
613 #undef gettext_nonempty
615 static unsigned char *
616 printhelp_cmd(struct option *option, unsigned char ***argv, int *argc)
618 unsigned char *lineend = strchr(full_static_version, '\n');
620 if (lineend) *lineend = '\0';
622 printf("%s\n\n", full_static_version);
624 if (!strcmp(option->name, "config-help")) {
625 printf("%s:\n", gettext("Configuration options"));
626 print_full_help(config_options, "");
627 } else {
628 printf("%s\n\n%s:\n",
629 gettext("Usage: elinks [OPTION]... [URL]..."),
630 gettext("Options"));
631 if (!strcmp(option->name, "long-help")) {
632 print_full_help(cmdline_options, "-");
633 } else {
634 print_short_help();
638 fflush(stdout);
639 return "";
642 static unsigned char *
643 redir_cmd(struct option *option, unsigned char ***argv, int *argc)
645 unsigned char *target;
647 /* I can't get any dirtier. --pasky */
649 if (!strcmp(option->name, "confdir")) {
650 target = "config-dir";
651 } else if (!strcmp(option->name, "conffile")) {
652 target = "config-file";
653 } else if (!strcmp(option->name, "stdin")) {
654 static int complained;
656 if (complained)
657 return NULL;
658 complained = 1;
660 /* Emulate bool option, possibly eating following 0/1. */
661 if ((*argv)[0]
662 && ((*argv)[0][0] == '0' || (*argv)[0][0] == '1')
663 && !(*argv)[0][1])
664 (*argv)++, (*argc)--;
665 fprintf(stderr, "Warning: Deprecated option -stdin used!\n");
666 fprintf(stderr, "ELinks now determines the -stdin option value automatically.\n");
667 fprintf(stderr, "In the future versions ELinks will report error when you will\n");
668 fprintf(stderr, "continue to use this option.\a\n");
669 return NULL;
671 } else {
672 return gettext("Internal consistency error");
675 option = get_opt_rec(cmdline_options, target);
676 assert(option);
677 option_types[option->type].cmdline(option, argv, argc);
678 return NULL;
681 static unsigned char *
682 printconfigdump_cmd(struct option *option, unsigned char ***argv, int *argc)
684 unsigned char *config_string;
686 /* Print all. */
687 get_opt_int("config.saving_style") = 2;
689 config_string = create_config_string("", "", config_options);
690 if (config_string) {
691 printf("%s", config_string);
692 mem_free(config_string);
695 fflush(stdout);
696 return "";
700 /**********************************************************************
701 Options values
702 **********************************************************************/
704 /* Keep options in alphabetical order. */
706 struct option_info cmdline_options_info[] = {
707 /* [gettext_accelerator_context(IGNORE)] */
708 INIT_OPT_BOOL("", N_("Restrict to anonymous mode"),
709 "anonymous", 0, 0,
710 N_("Restricts ELinks so it can run on an anonymous account.\n"
711 "Local file browsing, downloads, and modification of options\n"
712 "will be disabled. Execution of viewers is allowed, but entries\n"
713 "in the association table can't be added or modified.")),
715 INIT_OPT_BOOL("", N_("Autosubmit first form"),
716 "auto-submit", 0, 0,
717 N_("Automatically submit the first form in the given URLs.")),
719 INIT_OPT_INT("", N_("Clone internal session with given ID"),
720 "base-session", 0, 0, INT_MAX, 0,
721 N_("Used internally when opening ELinks instances in new windows.\n"
722 "The ID maps to information that will be used when creating the\n"
723 "new instance. You don't want to use it.")),
725 INIT_OPT_COMMAND("", NULL, "confdir", OPT_HIDDEN, redir_cmd, NULL),
727 INIT_OPT_STRING("", N_("Name of directory with configuration file"),
728 "config-dir", 0, "",
729 N_("Path of the directory ELinks will read and write its\n"
730 "config and runtime state files to instead of ~/.elinks.\n"
731 "If the path does not begin with a '/' it is assumed to be\n"
732 "relative to your HOME directory.")),
734 INIT_OPT_COMMAND("", N_("Print default configuration file to stdout"),
735 "config-dump", 0, printconfigdump_cmd,
736 N_("Print a configuration file with options set to the built-in\n"
737 "defaults to stdout.")),
739 INIT_OPT_COMMAND("", NULL, "conffile", OPT_HIDDEN, redir_cmd, NULL),
741 INIT_OPT_STRING("", N_("Name of configuration file"),
742 "config-file", 0, "elinks.conf",
743 N_("Name of the configuration file that all configuration\n"
744 "options will be read from and written to. It should be\n"
745 "relative to config-dir.")),
747 INIT_OPT_COMMAND("", N_("Print help for configuration options"),
748 "config-help", 0, printhelp_cmd,
749 N_("Print help for configuration options and exit.")),
751 INIT_OPT_CMDALIAS("", N_("MIME type assumed for unknown document types"),
752 "default-mime-type", 0, "mime.default_type",
753 N_("The default MIME type used for documents of unknown type.")),
755 INIT_OPT_BOOL("", N_("Ignore user-defined keybindings"),
756 "default-keys", 0, 0,
757 N_("When set, all keybindings from configuration files will be\n"
758 "ignored. It forces use of default keybindings and will reset\n"
759 "user-defined ones on save.")),
761 INIT_OPT_BOOL("", N_("Print formatted versions of given URLs to stdout"),
762 "dump", 0, 0,
763 N_("Print formatted plain-text versions of given URLs to stdout.")),
765 INIT_OPT_CMDALIAS("", N_("Codepage to use with -dump"),
766 "dump-charset", 0, "document.dump.codepage",
767 N_("Codepage used when formatting dump output.")),
769 INIT_OPT_CMDALIAS("", N_("Color mode used with -dump"),
770 "dump-color-mode", 0, "document.dump.color_mode",
771 N_("Color mode used with -dump.")),
773 INIT_OPT_CMDALIAS("", N_("Width of document formatted with -dump"),
774 "dump-width", 0, "document.dump.width",
775 N_("Width of the dump output.")),
777 INIT_OPT_COMMAND("", N_("Evaluate configuration file directive"),
778 "eval", 0, eval_cmd,
779 N_("Specify configuration file directives on the command-line\n"
780 "which will be evaluated after all configuration files has been\n"
781 "read. Example usage:\n"
782 "\t-eval 'set protocol.file.allow_special_files = 1'")),
784 /* lynx compatibility */
785 INIT_OPT_COMMAND("", N_("Interpret documents of unknown types as HTML"),
786 "force-html", 0, forcehtml_cmd,
787 N_("Makes ELinks assume documents of unknown types are HTML.\n"
788 "Useful when using ELinks as an external viewer from MUAs.\n"
789 "This is equivalent to -default-mime-type text/html.")),
791 /* XXX: -?, -h and -help share the same caption and should be kept in
792 * the current order for usage help printing to be ok */
793 INIT_OPT_COMMAND("", NULL, "?", 0, printhelp_cmd, NULL),
795 INIT_OPT_COMMAND("", NULL, "h", 0, printhelp_cmd, NULL),
797 INIT_OPT_COMMAND("", N_("Print usage help and exit"),
798 "help", 0, printhelp_cmd,
799 N_("Print usage help and exit.")),
801 INIT_OPT_BOOL("", N_("Only permit local connections"),
802 "localhost", 0, 0,
803 N_("Restricts ELinks to work offline and only connect to servers\n"
804 "with local addresses (ie. 127.0.0.1). No connections to remote\n"
805 "servers will be permitted.")),
807 INIT_OPT_COMMAND("", N_("Print detailed usage help and exit"),
808 "long-help", 0, printhelp_cmd,
809 N_("Print detailed usage help and exit.")),
811 INIT_OPT_COMMAND("", N_("Look up specified host"),
812 "lookup", 0, lookup_cmd,
813 N_("Look up specified host and print all DNS resolved IP addresses.")),
815 INIT_OPT_BOOL("", N_("Run as separate instance"),
816 "no-connect", 0, 0,
817 N_("Run ELinks as a separate instance instead of connecting to an\n"
818 "existing instance. Note that normally no runtime state files\n"
819 "(bookmarks, history, etc.) are written to the disk when this\n"
820 "option is used. See also -touch-files.")),
822 INIT_OPT_BOOL("", N_("Disable use of files in ~/.elinks"),
823 "no-home", 0, 0,
824 N_("Disables creation and use of files in the user specific home\n"
825 "configuration directory (~/.elinks). It forces default configuration\n"
826 "values to be used and disables saving of runtime state files.")),
828 INIT_OPT_CMDALIAS("", N_("Disable link numbering in dump output"),
829 "no-numbering", OPT_ALIAS_NEGATE, "document.dump.numbering",
830 N_("Prevents printing of link number in dump output.\n"
831 "Note that this really affects only -dump, nothing else.")),
833 INIT_OPT_CMDALIAS("", N_("Disable printing of link references in dump output"),
834 "no-references", OPT_ALIAS_NEGATE, "document.dump.references",
835 N_("Prevents printing of references (URIs) of document links\n"
836 "in dump output.\n"
837 "Note that this really affects only -dump, nothing else.")),
839 INIT_OPT_COMMAND("", N_("Control an already running ELinks"),
840 "remote", 0, remote_cmd,
841 N_("Control a remote ELinks instance by passing commands to it.\n"
842 "The option takes an additional argument containing the method\n"
843 "which should be invoked and any parameters that should be passed\n"
844 "to it. For ease of use, the additional method argument can be\n"
845 "omitted in which case any URL arguments will be opened in new\n"
846 "tabs in the remote instance.\n"
847 "Following is a list of the supported methods:\n"
848 "\tping() : look for a remote instance\n"
849 "\topenURL() : prompt URL in current tab\n"
850 "\topenURL(URL) : open URL in current tab\n"
851 "\topenURL(URL, new-tab) : open URL in new tab\n"
852 "\topenURL(URL, new-window) : open URL in new window\n"
853 "\taddBookmark(URL) : bookmark URL\n"
854 "\tinfoBox(text) : show text in a message box\n"
855 "\txfeDoCommand(openBrowser) : open new window")),
857 INIT_OPT_INT("", N_("Connect to session ring with given ID"),
858 "session-ring", 0, 0, INT_MAX, 0,
859 N_("ID of session ring this ELinks session should connect to. ELinks\n"
860 "works in so-called session rings, whereby all instances of ELinks\n"
861 "are interconnected and share state (cache, bookmarks, cookies,\n"
862 "and so on). By default, all ELinks instances connect to session\n"
863 "ring 0. You can change that behaviour with this switch and form as\n"
864 "many session rings as you want. Obviously, if the session-ring with\n"
865 "this number doesn't exist yet, it's created and this ELinks instance\n"
866 "will become the master instance (that usually doesn't matter for you\n"
867 "as a user much). Note that you usually don't want to use this unless\n"
868 "you're a developer and you want to do some testing - if you want the\n"
869 "ELinks instances each running standalone, rather use the -no-connect\n"
870 "command-line option. Also note that normally no runtime state files\n"
871 "are written to the disk when this option is used. See also\n"
872 "-touch-files.")),
874 INIT_OPT_BOOL("", N_("Print the source of given URLs to stdout"),
875 "source", 0, 0,
876 N_("Print given URLs in source form to stdout.")),
878 INIT_OPT_COMMAND("", NULL, "stdin", OPT_HIDDEN, redir_cmd, NULL),
880 INIT_OPT_BOOL("", N_("Touch files in ~/.elinks when running with -no-connect/-session-ring"),
881 "touch-files", 0, 0,
882 N_("When enabled, runtime state files (bookmarks, history, etc.) are\n"
883 "written to disk, even when -no-connect or -session-ring is used.\n"
884 "The option has no effect if not used in conjunction with any of\n"
885 "these options.")),
887 INIT_OPT_INT("", N_("Verbose level"),
888 "verbose", 0, 0, VERBOSE_LEVELS - 1, VERBOSE_WARNINGS,
889 N_("The verbose level controls what messages are shown at\n"
890 "start up and while running:\n"
891 "\t0 means only show serious errors\n"
892 "\t1 means show serious errors and warnings\n"
893 "\t2 means show all messages")),
895 INIT_OPT_COMMAND("", N_("Print version information and exit"),
896 "version", 0, version_cmd,
897 N_("Print ELinks version information and exit.")),
899 NULL_OPTION_INFO,