Chapter 5. Command-Line Parsing

Qore will scan the command-line for the options in the following table. Arguments after the script name will be passed to the script in the global $ARGV variable as a list of options. $ARGV[0] will be the first option and will not be the script name. If no script name is given and the --exec option is not used, then Qore code is read from standard input.

qore [options] script.q

Table 5.1. Parse Option Command-Line Parameters

Long Param

Short

Description

--load=arg

-l

Loads a module immediately. The argument can be a module/feature name or an absolute path to the module.

--no-global-vars

-G

Disallows the use of global variables. Equivalent to parse option PO_NO_GLOBAL_VARS and the %no-global-vars directive.

--no-subroutine-defs

-S

Disallows subroutine (function) definitions. Equivalent to parse option PO_NO_SUBROUTINE_DEFS and the %no-subroutine-defs directive.

--no-thread-control

-R

Disallows any thread control operations (background operator and thread_exit statement, for example). Equivalent to parse option PO_NO_THREAD_CONTROL and the %no-thread-control directive.

--no-thread-classes

n/a

Disallows access to thread classes (for example, the Thread::Mutex Class, Thread::Gate Class, Thread::Queue Class, etc). Equivalent to parse option PO_NO_THREAD_CLASSES and the %no-thread-classes directive.

--no-threads

-T

Disallows access to both thread control and thread classes (equivalent to the --no-thread-control and --no-thread-classes options documented above). Equivalent to parse option PO_NO_THREADS and the %no-threads directive.

--no-top-level

-L

Disallows top level code. Equivalent to parse option PO_NO_TOP_LEVEL_STATEMENTS and the %no-top-level directive.

--no-class-defs

n/a

Disallows class definitions. Equivalent to PO_NO_CLASS_DEFS and the %no-class-defs directive.

--no-namespace-defs

-D

Disallows new namespace definitions. Equivalent to PO_NO_NAMESPACE_DEFS and the %no-namespace-defs directive.

--no-external-process

-E

Disallows any access to external processes (with system(), backquote(), exec(), the backquote operator, etc). Equivalent to parse option PO_NO_EXTERNAL_PROCESS and the %no-external-process directive.

--no-process-control

-P

Disallows access to functions that would affect the current process (exit(), fork(), etc). Equivalent to parse option PO_NO_PROCESS_CONTROL and the %no-process-control directive.

--no-filesystem

-F

Disallows access to the local filesystem; puts the no-filesystem parse option in effect. Equivalent to parse option code PO_NO_FILESYSTEM and the %no-filesystem parse directive.

--no-constant-defs

n/a

Disallows constant definitions. Equivalent to parse option PO_NO_CONSTANT_DEFS and the %no-constant-defs directive.

--no-network

-Y

Disallows access to the network; puts the no-network parse option in effect. Equivalent to parse option code PO_NO_NETWORK and the %no-network parse directive.

--no-new

-N

Disallows use of the new operator. Equivalent to parse option PO_NO_NEW and the %no-new directive.

--no-database

-D

Disallows use of database functionality. Equivalent to parse option PO_NO_DATABASE and the %no-database directive.

--no-child-restrictions

-I

Allows child program objects to have parse option restrictions that are not a strict subset of the parents. Equivalent to parse option PO_NO_CHILD_RESTRICTIONS and the %no-child-restrictions directive.

--require-our

-O

Requires global variables to be declared with our prior to use (similar to perl's use strict vars pragma). Equivalent to parse option PO_REQUIRE_OUR and the %require-our directive.

--lock-options

-K

Prohibits further changes to parse options (equivalent to the %lock-options directive).

--lock-warnings

-A

Prohibits further changes to the warning mask. Equivalent to parse option PO_LOCK_WARNINGS and the %lock-warnings directive.

--enable-all-warnings

-W

Enables all warnings. Equivalent to the %enable-all-warnings directive.

--enable-warning=arg

-w

Enables the named warning. Equivalent to the %enable-warning directive.

--list-warnings

-i

Lists all valid warnings in Qore and exits immediately.


Table 5.2. Miscellaneous Command-Line Parameters

Long Param

Short

Description

--exec=ARG

-e

parses and executes the argument text as a Qore program. If this option is specified then any script given on the command-line will be ignored.

--exec-class[=ARG]

-x

parses and executes the argument text as a Qore program, instantiating the class with the same name as the program (with the directory path and extension stripped); also turns on --no-top-level. If the program is read from stdin or from the command-line, an argument must be given specifying the class name.

--show-module-errors

-m

Shows any errors loading Qore modules

--charset=ARG

-c

Sets the default character encoding for the program

--show-charset=ARG

Shows a list of all known character encodings

--show-aliases

Shows a list of all known character encoding aliases

--help

-h

Shows help text

--version

-v

Shows program version information and exits


There are two additional options available with debugging versions of Qore as follows:

Table 5.3. Description of Debugging Command-Line Parameters

Long Param

Short

Description

--debug=<arg>

-d<arg>

Turns on Qore debugging output. Higher arg numbers give more output. This option is only available with DEBUG builds.

--trace

-t

Turns on Qore tracing. This option is only available with DEBUG builds.