1array set help {
2    addtoc { Adds a "TOC" to a dir-tree, containing a full MD5 file index
3
4        Usage: addtoc dir
5    }
6    eval { Evaluate one Tcl command from the command line
7
8        Usage: eval cmd ?arg ...?
9    }
10    fetch { Fetch file from a HTTP or FTP server
11
12        Usage: fetch url ?destdir/file? ?chunksize?
13
14        If a destination dir is specified, the file will be stored
15        there under the same name as the original.
16    }
17    ftpd { World's smallest FTP server?
18
19        Usage: ftpd ?options?
20
21        -port      n      Port number to listen on (default: 8021)
22        -root      dir    Root of pages served (default: /ftproot)
23        -debug     n      Enable debug tracing level (default: 1)
24        -timeout   n      Server idle timeout seconds (default: 600)
25        -email     addr   This address is mentioned to send support emails to
26
27        Log output is also saved in the file "ftpd.log".
28    }
29    httpd { Simple HTTPD server by Steve Uhler and Brent Welch
30
31        Usage: httpd ?options?
32
33        -port      n      Port nunber to listen on (default: 8080)
34        -root      dir    Root of pages served (default: /wwwroot)
35        -default   file   File to use for dir (default: index.html)
36        -bufsize   n      Buffer size used for transfers (default: 32768)
37        -sockblock 0|1    Use blocking sockets (default: no)
38        -config    file   Read configurations from this file (default: none)
39        -launch    0|1    Launch a webbrowser on homepage (default: no)
40        -ipaddr    addr   Override listening IP address (default: std)
41    }
42    httpdist { Fetch/upload updates using the HTTPSYNC protocol
43
44        Usage:  httpdist @?url?                 Update in current directory
45                httpdist pack ?...?             Create packing list file
46                httpdist send ftpurl ?arch?     Upload through FTP
47
48        For more information, type "httpdist" without further parameters.
49        The HTTPSYNC protocol is described on this site:
50                http://www.mibsoftware.com/httpsync/
51    }
52    ls { A very simple Unix-like "ls" command in pure Tcl
53
54        Usage: ls ?-l? ?files/dirs?
55    }
56    lsk { List contents of a starkit or starpack
57
58        Usage: lsk starkit
59    }
60    md5sum { Calculate and print the MD5 message digest of files
61
62        Usage: md5sum files ?...?
63    }
64    mkinfo { Metakit file structure display
65
66        Usage: mkinfo file ?...?
67
68        Reports starting offset of Metakit data and structure of all views.
69    }
70    mkpack { Remove free space from Metakit file or starkit or starpack
71
72        Usage: mkpack infile outfile
73
74        The input file is written to the output file, removing any free
75        space which may have been created by subsequent commit changes.
76        The header of the datafile is copied intact to the output file,
77        the result is in every way equivalent but with an optimal size.
78    }
79    mkshow { MetaKit raw datafile dump/view utility
80
81        Usage: mkshow file view ?prop ...?
82
83        For more information, type "mkshow" without further parameters.
84    }
85    mksplit { Split starkit/starpack into head and tail files
86
87        Usage: mksplit file ?...?
88
89        File "foo/bar.kit" is copied to "foo.head" and "foo.tail", with
90        the head containing the starkit header (or raw executable), and
91        all Metakit data stored in the tail file.  See also mkinfo.
92    }
93    mkzipkit { Convert a zip archive into a Tcl Module or zipkit file
94
95        Usage: mkzipkit infile outfile ?stubfile?
96
97        Convert a zip archive into a Tcl Module or zipkit file by adding
98        a SFX header that can enable TclKit to mount the archive. This
99        provides an alternative to Metakit-based starkits. If no stubfile
100        is specified, a standard one using vfs::zip::mount will be used.
101    }
102    qwrap { Quick-wrap the specified source file into a starkit
103
104        Usage: qwrap file ?name? ?options?
105
106        -runtime   file   Take starkit runtime prefix from file
107
108        Generates a temporary .vfs structure and calls wrap to create
109        a starkit for you.  The resulting starkit is placed into file.kit
110        (or name.kit if name is specified). If the -runtime option is
111        specified a starpack will be created using the specified runtime
112        file instead of a starkit.
113
114        Note that file may be a local file, or URL (http or ftp).
115    }
116    ratarx { Reverse actions of a "tar x" command
117
118        Usage: ratarx ?-n? targzfile
119
120        This command deletes those files from a directory tree which have
121        the same size and modification date as in a specified targz file.
122        Empty directories are recursively deleted as final cleanup step.
123
124        The logic is such that deletion is "safe": only files/dirs which
125        are redundant (i.e. also present in the tar file) will be deleted.
126
127        The following two commands together will usually be a no-op:
128                tar xfz mydata.tar.gz
129                ratar mydata.tar.fz
130
131        Use the "-n" option to see what would be deleted without doing so.
132    }
133    rexecd { An rexec-compatible remote Tcl command server
134
135        Usage: rexecd ?options?
136
137        -port      n      Port nunber to listen on (default: 512)
138        -ipaddr    ip     Listen address (default: 0.0.0.0, all interfaces)
139    }
140    starsync { Starsync CGI server
141
142        Usage: starsync ?logfile?
143
144        Reads starsync input, returns HTTP response with starsync reply.
145        This is sufficient to create a starsync server which serves all
146        starkits found in the current directory (named *.kit).  Such a
147        server never alters anything, other than optionally appending one
148        line for each serviced request to the specified writable logfile.
149    }
150    sync { Synchronize two directory trees (either can use any type of VFS)
151
152        Usage: sync ?options? src dest
153
154        For more information, type "sync" without further parameters.
155    }
156    tgz2kit { Convert a tar/gz file to a starkit
157
158        Usage: tgz2kit ?-notop? inputfile
159
160        Output is a file in local dir with same name, but .kit extension.
161        The optional -notop flag strips top-level dirname from all paths.
162    }
163    treetime { Adjust modtimes in dir trees to match most recent file inside
164
165        Usage: treetime dirs...
166
167        Scans dir tree and resets mod dates on directories
168        to match the date of the newest files inside them.
169    }
170    unwrap { Unpack a starkit into a new directory
171
172        Usage: unwrap name
173
174        The name specified is the name of the starkit file.
175        The results are placed in a directory "name.vfs", which must
176        not yet exist.  The inverse of "unwrap" is called "wrap".
177    }
178    update { Fetch or update a starkit from a Starsync server (via http)
179
180        Usage: update ?-from url? ?-n? starkit
181
182        -from   url     Use specified Starsync server instead of default.
183        -n              Show differences, but do not make any changes.
184
185        Fetch changes so local starkit matches the one on the server.
186        The Starsync mechanism only transfers files which have changed.
187
188        Warning: this adds, modifies, *and* deletes files in the starkit.
189    }
190    version { Establish "version" of a starkit, based on what it contains
191
192        Usage: $argv0 ?-fixtime? file ...
193
194        Scans a starkit and produces a signature based on names of all
195        dirs and files in it, their sizes, and their modification dates.
196        Also reports modification time of newest file found (as GMT).
197
198        The "-fixtime" flag will adjust the starkit's modification time
199        to reflect that same time, this is merely a convenience feature.
200    }
201    wrap { Pack a file system directory area to a starkit
202
203        Usage: wrap name ?options?
204
205        -interp    name   Start something other than "tclsh" up
206        -nocomp           Do not compress files added to starkit
207        -runtime   file   Take starkit runtime prefix from file
208        -verbose          Report actions taken
209	-vfs       dir    Use this directory as the vfs tree
210        -writable         Allow modifications (must be single writer)
211
212        Expects a directory called "name.vfs", and creates a fresh
213        starkit from it, called "name".  The -vfs option lets you
214	use something other than "name.vfs".  If a starkit is specified
215	as runtime prefix, then files will be merged with it.
216    }
217}
218
219set cmd [lindex $argv 0]
220if {[info exists help($cmd)]} {
221    puts "\n$help($cmd)"
222    exit
223}
224
225cd [file dirname [info script]]
226set l [lsort [glob *.tcl]]
227puts "Specify one of the following commands:"
228
229foreach f $l {
230    set cmd [file rootname $f]
231    if {![info exists help($cmd)]} continue
232    switch -- $cmd {
233        help continue
234        main continue
235    }
236    if {$argv0 == "help"} {
237        puts [format {  %-10s %s} $cmd [lindex [split $help($cmd) \n] 0]]
238    } else { # called by default, so just enumerate all the known commands
239        puts -nonewline [format { %-9s} $cmd]
240    }
241}
242puts "\nFor more information, type:  $argv0 help ?command?"
243