25 #if defined (HAVE_CONFIG_H)
56 cmdline_options::cmdline_options (
void)
58 m_all_args.resize (1);
62 cmdline_options::cmdline_options (
int argc,
char **
argv)
87 m_read_history_file =
false;
91 m_no_window_system =
true;
95 m_verbose_flag =
true;
104 m_read_init_files =
false;
105 m_read_site_files =
false;
113 m_forced_interactive =
true;
122 m_inhibit_startup_message =
true;
149 if (m_code_to_eval.empty ())
189 m_forced_line_editing = m_line_editing =
true;
197 m_read_init_files =
false;
201 m_set_initial_path =
false;
205 m_line_editing =
false;
209 m_read_site_files = 0;
222 m_traditional =
true;
237 if (m_force_gui && m_no_gui)
239 warning (
"only one of --force-gui and --no-gui may be used");
248 cmdline_options::cmdline_options (
const cmdline_options& opts)
249 : m_force_gui (opts.m_force_gui),
250 m_forced_interactive (opts.m_forced_interactive),
251 m_forced_line_editing (opts.m_forced_line_editing),
252 m_inhibit_startup_message (opts.m_inhibit_startup_message),
253 m_line_editing (opts.m_line_editing),
254 m_no_gui (opts.m_no_gui),
255 m_no_window_system (opts.m_no_window_system),
256 m_persist (opts.m_persist),
257 m_read_history_file (opts.m_read_history_file),
258 m_read_init_files (opts.m_read_init_files),
259 m_read_site_files (opts.m_read_site_files),
260 m_set_initial_path (opts.m_set_initial_path),
261 m_traditional (opts.m_traditional),
262 m_verbose_flag (opts.m_verbose_flag),
263 m_code_to_eval (opts.m_code_to_eval),
264 m_command_line_path (opts.m_command_line_path),
265 m_exec_path (opts.m_exec_path),
266 m_image_path (opts.m_image_path),
267 m_all_args (opts.m_all_args),
268 m_remaining_args (opts.m_remaining_args)
272 cmdline_options::operator = (
const cmdline_options& opts)
276 m_force_gui = opts.m_force_gui;
277 m_forced_interactive = opts.m_forced_interactive;
278 m_forced_line_editing = opts.m_forced_line_editing;
279 m_inhibit_startup_message = opts.m_inhibit_startup_message;
280 m_line_editing = opts.m_line_editing;
281 m_no_gui = opts.m_no_gui;
282 m_no_window_system = opts.m_no_window_system;
283 m_persist = opts.m_persist;
284 m_read_history_file = opts.m_read_history_file;
285 m_read_init_files = opts.m_read_init_files;
286 m_read_site_files = opts.m_read_site_files;
287 m_set_initial_path = opts.m_set_initial_path;
288 m_traditional = opts.m_traditional;
289 m_verbose_flag = opts.m_verbose_flag;
290 m_code_to_eval = opts.m_code_to_eval;
291 m_command_line_path = opts.m_command_line_path;
292 m_exec_path = opts.m_exec_path;
293 m_image_path = opts.m_image_path;
294 m_all_args = opts.m_all_args;
295 m_remaining_args = opts.m_remaining_args;
303 application::application (
int argc,
char **argv)
304 : m_options (argc, argv)
309 application::application (
const cmdline_options& opts)
318 m_program_invocation_name =
pname;
322 m_program_name = (pos != std::string::npos) ? pname.substr (pos+1) :
pname;
337 m_argv.resize (nargs);
340 m_argv[
i] = args[
i+1];
347 void application::interactive (
bool arg)
349 interpreter *interp = instance->m_interpreter;
352 interp->interactive (arg);
355 bool application::forced_interactive (
void)
357 return instance->m_options.forced_interactive ();
360 bool application::interactive (
void)
362 interpreter *interp = instance->m_interpreter;
364 return interp ? interp->interactive () :
false;
367 application::~application (
void)
371 delete m_interpreter;
374 void application::create_interpreter (
void)
377 m_interpreter =
new interpreter (
this);
380 int application::execute_interpreter (
void)
382 return m_interpreter ? m_interpreter->execute () : -1;
385 void application::init (
void)
396 set_program_names (all_args[0]);
400 std::string code_to_eval = m_options.code_to_eval ();
402 m_have_script_file = ! remaining_args.
empty ();
404 if (! code_to_eval.empty () && m_have_script_file)
406 warning (
"--eval \"CODE\" and script file are mutually exclusive options");
411 m_is_octave_program = ((m_have_script_file || ! code_to_eval.empty ())
412 && ! m_options.persist ()
413 && ! m_options.traditional ());
422 int cli_application::execute (
void)
424 create_interpreter ();
426 return execute_interpreter ();
429 void embedded_application::create_interpreter (
void)
432 m_interpreter =
new interpreter (
this,
true);
435 int embedded_application::execute (
void)
437 create_interpreter ();
439 return execute_interpreter ();
452 octave::embedded_application app (argc, argv);
453 return app.execute ();
457 octave::cli_application app (argc, argv);
458 return app.execute ();
462 DEFUN (isguirunning, args, ,
475 return ovl (octave::application::is_gui_running ());
514 DEFUN (program_invocation_name, args, ,
529 return ovl (octave::application::program_invocation_name ());
537 DEFUN (program_name, args, ,
548 return ovl (octave::application::program_name ());
#define LINE_EDITING_OPTION
Octave interface to the compression and uncompression libraries.
static bool at_top_level(void)
OCTINTERP_API octave_value_list Fhistory_save(const octave_value_list &=octave_value_list(), int=0)
static void octave_print_version_and_exit(void)
OCTINTERP_API octave_value_list Finfo_program(const octave_value_list &=octave_value_list(), int=0)
would return a cell array of strings with the elements for an example of how to create an executable Octave script nd deftypefn *return ovl(Cell(octave::application::argv()))
OCTINTERP_API void print_usage(void)
OCTINTERP_API octave_value_list Fjit_enable(const octave_value_list &=octave_value_list(), int=0)
octave_idx_type numel(void) const
Number of elements in the array.
static std::string dir_sep_chars(void)
identity matrix If supplied two scalar respectively For allows like xample val
#define DEFUN(name, args_name, nargout_name, doc)
#define IMAGE_PATH_OPTION
OCTINTERP_API octave_value_list Fdebug_jit(const octave_value_list &=octave_value_list(), int=0)
#define NO_SITE_FILE_OPTION
int octave_main(int argc, char **argv, int embedded)
#define TRADITIONAL_OPTION
#define NO_LINE_EDITING_OPTION
OCTINTERP_API octave_value_list Ftexi_macros_file(const octave_value_list &=octave_value_list(), int=0)
#define TEXI_MACROS_FILE_OPTION
static void octave_print_terse_usage_and_exit(void)
OCTINTERP_API octave_value_list Fecho_executing_commands(const octave_value_list &=octave_value_list(), int=0)
#define panic_impossible()
static void assign(const std::string &name, const octave_value &value=octave_value(), scope_id scope=xcurrent_scope, context_id context=xdefault_context, bool force_add=false)
char * octave_optarg_wrapper(void)
void warning(const char *fmt,...)
octave_idx_type length(void) const
Number of elements in the array.
int octave_getopt_long_wrapper(int argc, char **argv, const char *shortopts, const struct octave_getopt_options *longopts, int *longind)
static void mark_hidden(const std::string &name, scope_id scope=xcurrent_scope)
=val(i)}if ode{val(i)}occurs in table i
static void set_program_name(const std::string &s)
static const char * short_opts
struct octave_getopt_options long_opts[]
#define DOC_CACHE_FILE_OPTION
#define BUILT_IN_DOCSTRINGS_FILE_OPTION
static void octave_print_verbose_usage_and_exit(void)
int octave_optind_wrapper(void)
OCTINTERP_API octave_value_list Finfo_file(const octave_value_list &=octave_value_list(), int=0)
#define NO_INIT_PATH_OPTION
void install_defaults(void)
#define NO_INIT_FILE_OPTION
OCTINTERP_API octave_value_list Fbuilt_in_docstrings_file(const octave_value_list &=octave_value_list(), int=0)
OCTINTERP_API octave_value_list Fdoc_cache_file(const octave_value_list &=octave_value_list(), int=0)
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
#define JIT_COMPILER_OPTION