Wapp

View Ticket
Login
Ticket Hash: 231e1accd3b5c1bb2ccc038bb99161941af9d743
Title: Add pkgIndex.tcl
Status: Open Type: Feature_Request
Severity: Important Priority:
Subsystem: Resolution:
Last Modified: 2023-09-06 07:54:33
1.75 years ago
Created: 2023-09-06 07:54:33
1.75 years ago
Version Found In: 1.0
User Comments:
anonymous added on 2023-09-06 07:54:33:

The documentation mentions that if you want to be able to package require wapp directly, you should build wapptclsh. However it's also very easy (and I would argue very useful) to set up wapp to be directly compatible with vanilla tclsh. If you put a pkgIndex.tcl file in the root dir with the following contents:

package ifneeded wapp 1.0 [list source [file join $dir wapp.tcl]]

... and make sure the root dir is directly or indirectly in auto_path, wapp will act as a normal Tcl package.

If you put the pkgIndex.tcl file and the following testwapp.tcl file inside the root dir:

lappend auto_path [file dirname [info script]]

package require wapp

proc wapp-default {} {
  wapp-subst {<h1>Hello, World!</h1>\n}
}
wapp-start $argv

You can get a "Hello World" page with just tclsh testwapp.tcl. If you install wapp as a system-wide library you won't need to touch the auto_path at all, this is just done for testing purposes here.

Adding a pkgIndex.tcl file would make wapp's usage identical to that of other Tcl packages like the ones in Tcllib and would make it easier to embed it in a larger Tcl application.