Once again the blog restarts! In the next few posts (hopefully every couple of days for the next few days) I aim to explain a bit more about my vision for Toucan, and what is being done and has been done to get there, hopefully culminating with the first development test of Toucan 3 at the end of the series. Topics will include scripting (in this post), Linux support, the improved command line interface, general improvements and a number of others. You might also want to check out the previous post Toucan 3 Teasers for a couple of quick pictures.
General & Scripting
A number of months ago I started thinking about the future of Toucan. Big changes were happening, I started my degree for example, and so I had to reassess everything that I work on. What I realised was two things, one that Toucan is something I seriously enjoy working on, and that in the future I would have to kick it into a higher gear to really help it pull away from the competition.
The first thing I did was to look at the features that Toucan currently offers and to pick out what was clearly the weakest one, the scripting functionality. As Toucan is aimed at a more advanced user base it was clear that the current language, a proprietary Toucan language with few commands and a few limited feature set wasn’t going to cut it. After investigating a number of alternatives, including Python and Tcl I chose Lua as the new back end for the scripting system.
Because it is a true programming language it has a huge amount of power, things that were impossible in the old language such as if statements and other loops, are built right in to Lua, allowing much more powerful scripts to be created. To give you an idea of what is possible here is the script shown in one of the teaser pictures from the last post
day = os.date(“%A”) if day == “Sunday” then print(“Never run the backup on a Sunday!”) else if day == “Saturday” then sync(“satjob”) else sync(“weekjob”) end if
As you can see this is far more useful than anything the old language was capable of, it chooses a different sync job to run on different days of the week, and warns the user that it should never be run on a Sunday. As well as the in built Lua commands, for a list see the Lua docs, you can see Toucan adds a few commands of its own, these are also more powerful than the current commands, the following is taken from the latest revisions to the helpfile:
7.7.1 syncvoid sync(string jobname)
jobname - The name of a previously saved Sync job.void sync(string source, string dest, string function, bool timestamps = false, bool attributes = false, bool ignorero = false, bool ignoredls = false, string rules = "")
source - The source folder for the sync.
dest - The destination folder for the sync.
function - One of Copy, Update, Mirror, Equalise, Move or Clean in the language Toucan is currently running in.
timestamps - If true then file and folder timestamps will be copied.
attributes - If true then file and folder attributes will be copied.
ignorero - If true then read only flags will be ignored.
ignoredls - If true then daylight saving adjustments will be ignored.
rules - The name of an existing set of Rules. If blank then no Rules are used.
As you can see there are now default entries for many of the options, a sensible set of defaults will be chosen with feedback closer to release.
Also as shown in the teaser picture Script now has a pretty syntax highlighted text entry box, which also supports the new Toucan commands, making it a much nicer environment to write complex scripts in.
Well that is quite enough for now, the next instalment will talk about the new command link interface which is being included, any questions please comment!