boo! stands for bash - object oriented! and is a small framework to add object oriented features to your linux system. it consists of a script named boo and a base object class.
the dot gray at gmx dot net
this software is released under the GPL.
| bash 2.05 or newer | http://www.gnu.org/software/bash/bash.html |
to use bo, you have to set up $BOO to the directory containing
your boo binary and the base object. this can be done in an easy
way by adding
$ eval "$(/path/to/boo -p)"
to your .bashrc. it may be more convenient to add this directory
to your $PATH, too.
objects are directories containing a .prototype link from which object
methods are inherited. all objects inherit from a base object class
$BOO/object - either directly or indirectly via the inheritance tree.
an object directory should contain a file named .description with a
textual description of the objects features for the internal help
system.
methods are simple script files within an object directory. they receive some preset variables when they are called:
$boo | the executable boo script |
$BOO | the boo installation directory and base directory for objects |
$THIS | the object the method was called on |
$SLOT | the name of the method called |
$METHOD | the method script currently executed |
a method script should contain a line starting with #+ describing its argument syntax. additionally, there should be one or more lines that start with #- and contain a textual description what the method does.
the illustrate how a method is called, i'll show you how to
use the internal help system to print out a description of
the base object class and all its methods:
$ object. help
you can prefix an objects name with a hostname and : to call a method
on an object on another host, if you have set up ssh access for
the current user without a passphrase.
the general syntax for method calls is as follows:
$ $boo [host:]object method [ args .. ]
for convenience, at object creation a link to the boo executable
will be created next to the object directory and with an added .
in its name. this allows you to shorten method calls to
$ object. method [ args ]
like it was done in the help system example.
if you use a regular file as an object in a boo call a virtual
prototype object is choosen by figuring the mime-type of the
file. for example, a text/plain file will use the object
$BOO/file/text/plain as its prototype. if that object does
not exist, $BOO/file/text and $BOO/file are tried.
note that the $BOO/file/text/plain object should use $BOO/file/text
as its prototype just like $BOO/file/text should use $BOO/file.
create a dog object
$ object. new dog
add a bark method
$ dog. method bark
iecho "woof!"
^[ZZ
call the method
$ dog. bark
remove the dog object
$ dog. destroy