comparison src/octave.cc @ 4356:b6ad3db48255

[project @ 2003-02-22 02:57:33 by jwe]
author jwe
date Sat, 22 Feb 2003 02:57:33 +0000
parents dcdca99fe2f0
children c45874c087c7
comparison
equal deleted inserted replaced
4355:6fa0c2306ef6 4356:b6ad3db48255
108 static bool verbose_flag = false; 108 static bool verbose_flag = false;
109 109
110 // Usage message 110 // Usage message
111 static const char *usage_string = 111 static const char *usage_string =
112 "octave [-?HVdfhiqvx] [--debug] [--echo-commands] [--exec-path path]\n\ 112 "octave [-?HVdfhiqvx] [--debug] [--echo-commands] [--exec-path path]\n\
113 [--help] [--info-file file] [--info-program prog] [--interactive]\n\ 113 [--funcall FUNC] [--help] [--info-file file] [--info-program prog]\n\
114 [--no-history] [--no-init-file] [--no-line-editing] [--no-site-file]\n\ 114 [--interactive] [--no-history] [--no-init-file] [--no-line-editing]\n\
115 [-p path] [--path path] [--silent] [--traditional] [--verbose]\n\ 115 [--no-site-file] [-p path] [--path path] [--silent] [--traditional]\n\
116 [--version] [file]"; 116 [--verbose] [--version] [file]";
117 117
118 // This is here so that it's more likely that the usage message and 118 // This is here so that it's more likely that the usage message and
119 // the real set of options will agree. Note: the `+' must come first 119 // the real set of options will agree. Note: the `+' must come first
120 // to prevent getopt from permuting arguments! 120 // to prevent getopt from permuting arguments!
121 static const char *short_opts = "+?HVdfhip:qvx"; 121 static const char *short_opts = "+?HVdfhip:qvx";
122 122
123 // The name of the optional initial function to call at startup.
124 // (--funcall FUNC)
125 static std::string fun_to_call;
126
123 // Long options. See the comments in getopt.h for the meanings of the 127 // Long options. See the comments in getopt.h for the meanings of the
124 // fields in this structure. 128 // fields in this structure.
125 #define EXEC_PATH_OPTION 1 129 #define EXEC_PATH_OPTION 1
126 #define INFO_FILE_OPTION 2 130 #define FUNCALL_OPTION 2
127 #define INFO_PROG_OPTION 3 131 #define INFO_FILE_OPTION 3
128 #define NO_INIT_FILE_OPTION 4 132 #define INFO_PROG_OPTION 4
129 #define NO_LINE_EDITING_OPTION 5 133 #define NO_INIT_FILE_OPTION 5
130 #define NO_SITE_FILE_OPTION 6 134 #define NO_LINE_EDITING_OPTION 6
131 #define TRADITIONAL_OPTION 7 135 #define NO_SITE_FILE_OPTION 7
136 #define TRADITIONAL_OPTION 8
132 long_options long_opts[] = 137 long_options long_opts[] =
133 { 138 {
134 { "debug", prog_args::no_arg, 0, 'd' }, 139 { "debug", prog_args::no_arg, 0, 'd' },
135 { "braindead", prog_args::no_arg, 0, TRADITIONAL_OPTION }, 140 { "braindead", prog_args::no_arg, 0, TRADITIONAL_OPTION },
136 { "echo-commands", prog_args::no_arg, 0, 'x' }, 141 { "echo-commands", prog_args::no_arg, 0, 'x' },
137 { "exec-path", prog_args::required_arg, 0, EXEC_PATH_OPTION }, 142 { "exec-path", prog_args::required_arg, 0, EXEC_PATH_OPTION },
143 { "funcall", prog_args::required_arg, 0, FUNCALL_OPTION },
138 { "help", prog_args::no_arg, 0, 'h' }, 144 { "help", prog_args::no_arg, 0, 'h' },
139 { "info-file", prog_args::required_arg, 0, INFO_FILE_OPTION }, 145 { "info-file", prog_args::required_arg, 0, INFO_FILE_OPTION },
140 { "info-program", prog_args::required_arg, 0, INFO_PROG_OPTION }, 146 { "info-program", prog_args::required_arg, 0, INFO_PROG_OPTION },
141 { "interactive", prog_args::no_arg, 0, 'i' }, 147 { "interactive", prog_args::no_arg, 0, 'i' },
142 { "no-history", prog_args::no_arg, 0, 'H' }, 148 { "no-history", prog_args::no_arg, 0, 'H' },
282 Options:\n\ 288 Options:\n\
283 \n\ 289 \n\
284 --debug, -d Enter parser debugging mode.\n\ 290 --debug, -d Enter parser debugging mode.\n\
285 --echo-commands, -x Echo commands as they are executed.\n\ 291 --echo-commands, -x Echo commands as they are executed.\n\
286 --exec-path PATH Set path for executing subprograms.\n\ 292 --exec-path PATH Set path for executing subprograms.\n\
293 --funcall FUNC Call Octave function FUNC with no arguments.\n\
287 --help, -h, -? Print short help message and exit.\n\ 294 --help, -h, -? Print short help message and exit.\n\
288 --info-file FILE Use top-level info file FILE.\n\ 295 --info-file FILE Use top-level info file FILE.\n\
289 --info-program PROGRAM Use PROGRAM for reading info files.\n\ 296 --info-program PROGRAM Use PROGRAM for reading info files.\n\
290 --interactive, -i Force interactive behavior.\n\ 297 --interactive, -i Force interactive behavior.\n\
291 --no-history, -H Don't save commands to the history list\n\ 298 --no-history, -H Don't save commands to the history list\n\
301 \n\ 308 \n\
302 FILE Execute commands from FILE.\n\ 309 FILE Execute commands from FILE.\n\
303 \n\ 310 \n\
304 Additional information about Octave is available via the WWW at\n\ 311 Additional information about Octave is available via the WWW at\n\
305 http://www.octave.org.\n\ 312 http://www.octave.org.\n\
306 \n\ 313 \n"
307 Please report bugs to the bug-octave@bevo.che.wisc.edu mailing list.\n"; 314 OCTAVE_CONTRIB_STATEMENT "\n\
315 \n"
316 OCTAVE_BUGS_STATEMENT "\n";
308 317
309 exit (0); 318 exit (0);
310 } 319 }
311 320
312 // Terse usage messsage. 321 // Terse usage messsage.
459 case EXEC_PATH_OPTION: 468 case EXEC_PATH_OPTION:
460 if (args.optarg ()) 469 if (args.optarg ())
461 bind_builtin_variable ("EXEC_PATH", args.optarg ()); 470 bind_builtin_variable ("EXEC_PATH", args.optarg ());
462 break; 471 break;
463 472
473 case FUNCALL_OPTION:
474 if (args.optarg ())
475 fun_to_call = args.optarg ();
476 break;
477
464 case INFO_FILE_OPTION: 478 case INFO_FILE_OPTION:
465 if (args.optarg ()) 479 if (args.optarg ())
466 bind_builtin_variable ("INFO_FILE", args.optarg ()); 480 bind_builtin_variable ("INFO_FILE", args.optarg ());
467 break; 481 break;
468 482
593 } 607 }
594 608
595 if (! interactive) 609 if (! interactive)
596 line_editing = false; 610 line_editing = false;
597 611
598 int retval = main_loop (); 612 int retval = main_loop (fun_to_call);
599 613
600 if (retval == 1 && ! error_state) 614 if (retval == 1 && ! error_state)
601 retval = 0; 615 retval = 0;
602 616
603 clean_up_and_exit (retval); 617 clean_up_and_exit (retval);