Eskil

Plugins
Login

Introduction

Eskil provides a plugin system where a plugin can preprocess data before being compared and displayed.

A plugin is a Tcl script that must follow a specific format. Example plugins are included in the kit. Dump one of the included plugins to see what it looks like.

When searching for a plugin "x", files "x" and "x.tcl" will match. The search path is current directory, "plugins" directory, the directory where Eskil is installed, "plugins" directory where Eskil is installed, and also the internal "plugins" wrapped into Eskil.

Usage

The command line options for plugins are:

A plugin may further define command line options that it accepts. A way to see the plugin's options is to do:

eskil -plugin <plg> -help

Multiple -plugin may be given and they will be applied in the given order. Any -plugininfo and -pluginallow belongs to the last -plugin before them.

General Format

A plugin is a Tcl script file that must start with the verbatim sequence "##Eskil Plugin :". A plugin is sourced and used in its own safe interpreter and thus have free access to its own global space. Hookup points are defined by declaring specifically named procedures as specified below, and apart from those, a plugin can define and do whatever within the limits of a safe interpreter.

In addition to the standard safe interpreter environment, a plugin has access to stdout as well. By using the command line option -pluginallow, the plugin is run in a standard interpreter and may e.g. do exec to utilize external tools.

A plugin is set up with these global variables filled in:

Additional options

A plugin can declare command line options that should be accepted by Eskil. They will be passed on to the plugin through the ::argv list. If the initial "##Eskil" line is followed by comments formatted as below, it adds options. Any empty line will end parsing for such lines.

A line like "## Option -<option>" declares an option that takes a value and a line like "## Flag -<option>" declares an option without value. The rest of the line after the option name is functionally ignored and can be used for comments. It is included in command line help, so the rest should preferably be formatted as " : Explanation" if used.

File plugin

To process the files being compared, the following procedure should be defined in the plugin file:

proc PreProcess {side chi cho} {...}

The arguments given to PreProcess are:

A plugin may give a result that has a line-by-line correspondence to the original, in which case the preprocessed data is used for comparing while the original is used for displaying. The PreProcess procedure should return 0 to signify this case.

If the PreProcess procedure returns 1, the processed data is used also for displaying.

If Eskil is run with Tcl 8.6 or newer, PreProcess is run as a coroutine and may yield. The left and right side will then be called alternately until they return. This allows a plugin to take both sides into account for decisions if needed.

Directory plugin

To be used for file comparison in a directory diff, the following procedure should be defined in the plugin file:

proc FileCompare {ch1 ch2 info1 info2} {...}

The arguments given to FileCompare are:

Info dictionaries contain at least elements "name" and "size".

The FileCompare procedure can give the following return values:

Directory diff only supports one plugin. The first plugin with FileCompare defined will be used.