Wapp - fork of wapp.tcl.tk

Let's give wapp.tcl.tk a new dimension

This is a fork of wapp.tcl.tk, maintained with custom changes and updates. This fork is not a bug-fix release, but a personal adaptation to better suit my development needs. For more details on changes, check the Github project repository .

wapptclsh

  • Is a pure C program, while the static tclsh is a ZipFS binary first and only then a C program. :)
  • Runs as an interactive shell (REPL) when executed without arguments.
  • Can be used for CLI scripting as an alternative to tclsh.
  • Functions as a CGI interpreter for writing web applications.
  • Includes a straightforward mechanism for compiling any Tcl code directly into it
  $: ./wapptclsh

   _ _ _
  | | | |___ ___ ___
  | | | | .'| . | . |
  |_____|__,|  _|  _|
            |_| |_|

  Wapp 1.0 shell using SQLite version 3.50.0 and TCL 9.0
  % Markdown::convert "# Heading1"
  <h1>Heading1</h1>
  % datetime "%Y-%m-%d %H:%M:%S" "'now', '+1 day'"
  2025-02-21 07:06:50
  % datetime "%Y-%m-%d %H:%M:%S" "'now', '+1 day', 'localtime'"
  2025-02-21 08:07:13
  %

  $: ./wapptclsh script.tcl
  Hello World!

  Implement proc main in the app.tcl and ship it as a single file
  $: echo 'proc main {} { puts "All in one" }' >> app.tcl && make
  $: ./wapptclsh
  All in one

  $: echo 'proc wapp-default {} { wapp-trim { Hello web! } }; wapp-start $argv' > index.cgi
  $: ./wapptclsh index.cgi --server 8082
  Listening for HTTP requests on TCP port 8082
  $: curl http://localhost:8082
  Hello web!

Changelog

  • proc test
     Added as a no-nonsense test helper. Takes an expected value—either 
     a fixed one or a regex wrapped in //. Ditch the bloated test suites.
     % test test-1.0 {string match value value} {1}
     PASS: test-1.0
     % test test-1.1 {string match value value2} {1}
     FAIL: test-1.1, want: 1, got: 0 line: 1
     % test test-1.2 { set x foo123 } {/foo[0-9]+/}
     PASS: test-1.2
     % test test-1.3 { set x foo123a } {/foo[0-9]+/}
     FAIL: test-1.3, want: foo[0-9]+, got: foo123a line: 1
     See: functions.tcl : proc test
  • proc parray
     Added as a replacement for the missing parray command and for convenience.
     % parray myArray "ba*"
     % parray myArray "*" "value*"
     See: functions.tcl : proc parray
  • proc datetime
     Added as a replacement for the missing clock command and for convenience.
     % datetime "%Y-%m-%d %H:%M:%S" "'now', '+1 day'"
     % datetime "%Y-%m-%d" "'now','start of year','+9 months','weekday 2'"
     See: functions.tcl : proc datetime
  • proc wapp-set-cookie/wapp-clear-cookie
     Now support setting an expiry time and a secure flag for web applications

     wapp-set-cookie session val
     wapp-set-cookie session-secure val 0 secure
     wapp-set-cookie timed val 3600
     wapp-set-cookie timed-secure val 3600 secure

     wapp-clear-cookie session
     wapp-clear-cookie session-secure "" -1 secure
     wapp-clear-cookie timed "" -1
     wapp-clear-cookie timed-secure "" -1 secure