10.3 The usage of command line parameters and string functions
All the commands have the same structure: the first parameter
is a case-sensitive command name (with no
- or
/ prefix). The command name shows how
many arguments it expects according to the number of colons in the name:
logoutAndExit expects no arguments, setProject: expects one argument, and
loginDB:user:password: expects three arguments – a database name, user
name, and password. Note that for commands that expect arguments, there are no
spaces in the command name, and the last character is always a colon.
After a command name expecting N arguments, the next N
parameters on the command line will be used as those arguments. If a parameter
contains a space, you will need to escape it or quote the parameter according to
the rules of your platform.
As an example, consider the following command line that
would login to the ‘demo’ repository, open the ‘Watch’
project, run the ‘Autobuild’ generator for all WatchFamily diagrams,
and then logout:
mep55.exe loginDB:user:password: demo user user setProject: Watch forAll:run: WatchFamily Autobuild commit logoutAndExit
Here,
mep55.exe is the name of the MetaEdit+
program executable. The first parameter given to the executable is
loginDB:user:password: with its
arguments demo,
user and
user. The second command is
setProject: with its argument
Watch. The third command,
forAll:run:, is followed by its two
arguments: WatchFamily and
Autobuild. The last two commands,
commit and
logoutAndExit, do not have any
arguments.
Unrecognized commands will be logged to log.txt (also when
calling from MERL):
Command not found: foobar
If too few arguments are
supplied for a command, this will be logged to log.txt:
Not enough arguments for command: forAll:run: - expected 2, got 1: 'barfoo'
Note
that if there are subsequent commands after the insufficient arguments, they
will be interpreted as the missing arguments. (Most commands take freeform
strings as arguments, so there is no real way to distinguish.)
Please note that if you start the API from the command
line, you do not want to add the
logoutAndExit command into that same
command line – if you do, the execution of MetaEdit+ is halted before your
API utilization can take place. So, do not logout from the command line, but
instead call logoutAndExit as the final API command.
When using the API from a generator, it is best to start
the API with internal...execute, but have the program that will use it close it
with an API call to stopAPI. Alternatively a generator can send stopAPI first (a
no-op if none are running), then startAPI. This will ensure that there is just
one API Tool running.