Commit 4dbeabf2 authored by twanvl's avatar twanvl

Documentation of command line interface

parent 80b8d818
Interactive command line interface
DOC_MSE_VERSION: since 0.3.7
--Description--
]]mse --cli [<em>my-set.mse-set</em>]
The MSE interactive command line interface provides a way to work with set files without a graphical environment.
The CLI shows a prompt where commands can be entered, which are then executed by MSE.
--Commands--
! Command Short version Description
| @:help@ @:?@ Show a help screen describing the available commands.
| @:quit@ @:q@ Quit the interactive cli.
| @:load@ @:l@ Load a set file. The current set will be unloaded.
For example:
]:load my-set.mse-set
| @:reset@ @:r@ Clear all variable definitions.
| @:!@ Perform a shell command. For example @:! dir@ shows a directory listing.
| ''other'' Execute the command as a line of [[type:script]] code.
The script has access to the loaded set and all [[fun:index|built in functions]].
--Raw mode--
]mse.exe --cli --raw
For interfacing MSE with other programs the raw mode is most convenient.
In the raw mode the only output is in response to commands.
For each command a single ''record'' is written to the standard output.
The records consists of:
* A line with an integer status code, @0@ for ok, @1@ for warnings, @2@ for errors.
* A line containing an integer ''k'', the number of lines to follow.
* ''k'' lines, each containing UTF-8 encoded string data.
Strings are not further encoded or escaped.
In this mode multi line strings can be transfered from MSE without much encoding/parsing hastle.
The behaviour of the raw mode is guaranteed not to change between versions of MSE (subject to bugs and changes in the scripting language),
for the normal mode no such guarantee is made.
--Example--
Here is an example session, the text entered by the user is shown in blue.
]]$ <span class="hl-input">mse --cli</span>
] ___
] __ __ _ ___ _ ___ _ _ _ |__ \
] | \/ |__ _ __ _(_)__ / __|___| |_ | __|__| (_) |_ ___ _ _ ) |
] | |\/| / _` / _` | / _| \__ | -_) _| | _|/ _` | | _/ _ \ '_| / /
] |_| |_\__,_\__, |_\__| |___|___|\__| |___\__,_|_|\__\___/_| / /_
] |___/ |____|
]
]]> <span class="hl-input">:load myset.mse-set</span>
]]> <span class="hl-input">first_card := set.cards.0 <span class="hl-comment"># the first card</span></span>
][[card]]
>>>>> <span class="hl-input">first_card.name</span>
]"Pineapple of Doom"
>>>>> <span class="hl-input">write_image_file(first_card, file: "firstcard.jpg")</span>
]]> <span class="hl-comment"># the image file "firstcard.jpg" is now saved</span>
]]> <span class="hl-input">:! dir</span>
]2008-08-04 22:57 92 891 firstcard.jpg
] 1 File(s) 92 891 bytes
] 0 Dir(s) 986 562 560 bytes free
]]> <span class="hl-input">:reset</span>
]]> <span class="hl-input">first_card.name <span class="hl-comment"># variable was cleared</span></span>
]]<span style="color:red">ERROR:</span> Variable not set: first_card
]]> <span class="hl-input">:quit</span>
]Goodbye
MSE Command line
Magic set editor can be started from the command prompt by typing:
]mse
in Windows, or
]magicseteditor
on other platforms.
The MSE program has several flags for choosing different behaviour.
--Starting the GUI--
]mse
Invoking MSE with no arguments shows the welcome window.
]]mse <em>my-set.mse-set</em>
Invoking MSE with the filename of a [[type:set]] shows the main window with that set loaded.
This command is automatically invoked when you double click on a set file in a file manager.
]mse my-symbol.mse-symbol
Invoking MSE with the filename of a [[type:symbol]] shows the symbol editor window with that symbol loaded.
]mse --symbol-editor
With the <tt>--symbol-editor</tt> flag the symbol editor is started with a blank symbol.
--Information about MSE--
]mse --version
The <tt>--version</tt> flag (abbreviate as <tt>-v</tt>) writes the version number of MSE to the standard output,
or in a message box if MSE was not started from the command prompt.
]mse --help
The <tt>--help</tt> flag (abbreviate as <tt>-?</tt>) displays a list of available flags to the standard output,
or in a message box if MSE was not started from the command prompt.
--Installers--
]]mse <em>my-installer.mse-installer</em>
Invoking MSE with the filename of an [[type:installer]] shows the package window, from where the packages in that installer can be installed.
By passing the <tt>--local</tt> or <tt>--global</tt> flag you can change where the package will be installed.
Global installation is for all users, local installation is for the current user only (see [[file:index|data directories]]).
]mse --create-installer <em>output.mse-installer</em> <em>package1.mse-game</em> <em>package2.mse-game</em> ...
Creates an installer package containing one or more packages from the mse [[file:index|data directory]].
The installer will be written to <tt><em>output.mse-installer</em></tt>. This name can be ommitted, in which case the name of the forst package will be used (in this case <tt>package1.mse-installer</tt>).
--Interactive cli interface--
]mse --cli
Starts the [[cli:cli|Interactive command line interface]].
Optionally the filename of a set can be passed which will then be loaded.
......@@ -6,6 +6,9 @@ These documents describe the file formats and scirpting language used by the pro
There is currently no information on how to ''use'' the program for making cards.
--Topics--
Using the program:
* [[doc/cli|Invoking MSE from the command line]]
Templates:
* [[doc/tutorial|Templating tutorial]] (comming soon)
* [[doc/file|File formats]]
* [[doc/type|Data types used in the files]]
......
......@@ -3405,6 +3405,12 @@
<Filter
Name="about"
Filter="">
<File
RelativePath="..\doc\about\index.txt">
</File>
<File
RelativePath="..\doc\about\license.txt">
</File>
</Filter>
<Filter
Name="file"
......@@ -3745,6 +3751,15 @@
<File
RelativePath="..\doc\type\map.txt">
</File>
<File
RelativePath="..\doc\type\pack_item.txt">
</File>
<File
RelativePath="..\doc\type\pack_item_reference.txt">
</File>
<File
RelativePath="..\doc\type\pack_type.txt">
</File>
<File
RelativePath="..\doc\type\regex.txt">
</File>
......@@ -3815,6 +3830,19 @@
RelativePath="..\doc\type\word_list_word.txt">
</File>
</Filter>
<Filter
Name="cli"
Filter="">
<File
RelativePath="..\doc\cli\cli.txt">
</File>
<File
RelativePath="..\doc\cli\flags.txt">
</File>
<File
RelativePath="..\doc\cli\index.txt">
</File>
</Filter>
</Filter>
<Filter
Name="cli"
......
......@@ -145,11 +145,15 @@ function autoformat__handle(&$i, $prefix, $first, $fail_same = false) {
$state = '>';
} elseif ($line{0} == ']') {
// other code
if ($state == ']') $text = substr($text,0,-6);
if ($state == '>') $text = substr($text,0,-6);
else $text .= '<pre>';
$text .= htmlspecialchars(substr($line, 1));
if (substr($line,0,2)==']]') { // unescaped
$text .= substr($line, 2);
} else {
$text .= htmlspecialchars(substr($line, 1));
}
$text .= "\n</pre>";
$state = ']';
$state = '>';
// Html
} elseif (preg_match("@^</?(pre|ul|ol|li|div|blockquote|>)@", $line)) {
......@@ -285,7 +289,7 @@ function autoformat__link_s($matches) {
}
function autoformat__url($url) {
if (preg_match("/^(type|fun|script|file):(.*)/i",$url,$matches)) {
if (preg_match("/^(type|fun|script|file|cli):(.*)/i",$url,$matches)) {
$part = $matches[1];
if ($part == 'fun') $part = 'function';
$sub = str_replace(' ','_',strtolower($matches[2]));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment