A Tcl Packaging Tool
Tarcel allows you to combine a number of files together to create a
single tarcel file that can be run by tclsh, wish, or can be sourced into
another Tcl script. This makes it easy to distribute your applications as
a single file. In addition it allows you to easily create Tcl modules
made up of several files including shared libraries, and then take
advantage of the extra benefits that Tcl modules provide such as faster
loading time.
Project page:
http://vlifesystems.com/projects/tarcel/
Github:
https://github.com/LawrenceWoodman/tarcel
Changes:
Tarvel v0.3 allows you to add a hashbang line to the resulting tarcel
package and corrects the use of the args variable passed in to another
tarcel.
Example:
As an example, if you have the following files that you would like to
put together to form a module called
translator-0.1.tm:
translator.tcl
lib/deutsch.tcl
lib/english.tcl
lib/italiano.tcl
translator.tcl contains:
namespace eval translator {
variable translations [dict create]
}
proc translator::addTranslations {language _translations} {
variable translations
dict set translations $language $_translations
}
source lib/deutsch.tcl
source lib/english.tcl
source lib/italiano.tcl
proc translator::englishTo {language englishWord} {
variable translations
dict get $translations $language $englishWord
}
lib/deutsch.tcl contains:
translator::addTranslations deutsch {
welcome willkommen
}
lib/english.tcl contains:
translator::addTranslations english {
welcome welcome
}
lib/italiano.tcl contains:
translator::addTranslations italiano {
welcome benvenuti
}
You can create a module,
translator-0.1.tm, from these files using the
following translator.tarcel file:
set files [list \
translator.tcl \
[file join lib deutsch.tcl] \
[file join lib english.tcl] \
[file join lib italiano.tcl]
]
set version 0.1
set baseDir translator-$version.vfs
set outputFilename translator-$
version.tm
import [file join $baseDir app] $files
config set version $version
config set homepage "
http://example.com/project/translator"
set initScript {
source [file join @baseDir app translator.tcl]
}
config set init [string map [list @baseDir $baseDir] $initScript]
config set outputFilename $outputFilename
Wrap the files into a module using the following:
$ tclsh tarcel.tcl wrap translator.tarcel
Now create a test file, translator.test.tcl:
package require tcltest
namespace import tcltest::*
::tcl::tm::path add [file normalize .]
package require translator
test englishTo-1 {Ensure translates from English to German} -body {
translator::englishTo deutsch welcome
} -result {willkommen}
test englishTo-2 {Ensure translates from English to Italian} -body {
translator::englishTo italiano welcome
} -result {benvenuti}
cleanupTests
Finally you can now run the test and see that it treats the module just
as if it was originally created as a single file:
$ tclsh translator.test.tcl
Feedback and contributions:
Both are very welcome and ideally should be made via GitHub or failing
that to me directly:
lwoo...@vlifesystems.com
Licence:
The module is released under an MIT licence.
Best Wishes
Lorry
--
vLife Systems Ltd
Registered Office: The Apex, 2 Sheriffs Orchard, Coventry, CV1 3PP
Registered in England and Wales No. 06477649
http://vlifesystems.com