Extension Interface¶
The Dish shell is extended through modules. These modules must have a function
called register_extension
, which must accept the Dish
objects as an
argument. The function has to initialize the extension by setting properties on
the Dish
object, which are listed below. If you still don’t understand how
to write extensions, you can read the source code of the built-in
extensions as an example.
-
Dish.
start_tag_handlers
= {}¶ This is a dictionary of functions used to handle start tags in prompts. These functions accept one argument, which is a dictionary containing the XML tag’s attributes. The function must return a string to replace the tag with.
For example, when the prompt parser encounters
<thing value="8">
, it will callself.start_tag_handlers['thing']({'value': '8'})
.
-
Dish.
end_tag_handlers
= {}¶ This is just like
start_tag_handlers
, but it’s for end tags, and the functions in it accept no arguments. If you want to create a self-closing tag, such as<cwd/>
, then you only need to add a function tostart_tag_handlers
.
-
Dish.
prompt_predicates
= {}¶ This is a dictionary of functions that accept no arguments and return a boolean value. These functions are used for
<if_...>
tags.