Command Line Switches

Command Line Switches

Euphoria provides several products: interpreter, binder, translator, and compiler. A product may be launched with an optional command line switch to customize its behavior.

product ==: eui | euiw | eushroud | eubind | eub | euc 
product [switch_list] [file_name] [user_text] 
-- launch the hello world program: 
    -->>    eui hello.ex            -- typical, no switches 
-- launch with a switch 
    -->>  eui -strict hello.ex       -- switch: enable all warning messages      
-- launch with command line text      
    -->> eui hello.ex fido           -- optional user supplied text 
                                     -- which can be read by the program 
-- display copyright information: 
    -->>    eui - copyright          -- no file_name needed    

Command line switches are written into a switch_list. A switch may be followed by an argument, there can be any number of switches, duplicate switches are permitted, and switches are delimited by blanks.

A configuration file is a text file containing command line switches. This is a text file containing one switch per line. See: Configuration File Format.

Switches are added to the switch_list from these sources:

  • A switch_list can be introduced in the command line when a product is launched.
  • A switch_list in the command line can contain the -c switch. This reads a configuration file and inserts switches into the switch_list.
  • Configuration files may contain -c switches. This allows configuration files to be nested.
  • Euphoria searches a few standard locations, in fixed order, for eu.cfg configuration files; as switches are found they are appended to the switch_list.
  • Euphoria installations have a default eu.cfg file containing the path to the standard library.

The -c switch reads a configuration file. This switch may be entered at the command line, or may be contained inside a configuration file, and the argument can have any file name and extension. When the -c switch is read from a configuration file, the new file is processed completely, and then the prior file continues to be processed. The -c switch supports nesting of configuration files; however, each file is processed only once.

A typical Euphoria installation will have one configuration file installed by default. The file eu.cfg contains a switch with the path to the Euphoria include files and standard library. That means every switch_list will contain at least this one switch. See: Sample Configuration Files

  • The arguments for a later switch may override previous settings:

eui -eudir dir hello.ex 

  • A search path using the -i switch is inserted ahead of existing paths. The search for an include file ends at the first valid file. While the previous search paths still exist and may be searched, a -i path insertion can effectively shadow these paths.
  • The arguments for a switch may be cumulative. For example, the -d switch adds a new word each time it is used.

-- test.ex 
ifdef blue then 
    puts(1, "word is blue\n") 
end ifdef 
ifdef red then 
    puts(1, "word is red\n") 
end ifdef 

Command Result
eui test.ex "empty"
eui -d blue test.ex

word is blue
eui -d red -d blue test.ex

word is blue
word is red

Finally, any user_text following file_name may be read from a program using the command_line function. Otherwise, this text is ignored.


Quick Links

User menu

Not signed in.

Misc Menu