1# -*- tcl -*-
2# (C) 2006 Andreas Kupries <andreas_kupries@users.sourceforge.net>
3##
4# ###
5
6namespace eval ::sak::help {}
7
8# ###
9
10proc ::sak::help::print {text} {
11    global critcldefault
12    puts stdout [string map \
13	    [list @@ $critcldefault] $text]
14    return
15}
16
17proc ::sak::help::on {topic} {
18    variable base
19
20    # Look for static text and dynamic, i.e. generated help.
21    # Static is prefered.
22
23    set ht [file join $base $topic help.txt]
24    if {[file exists $ht]} {
25	return [get_input $ht]
26    }
27
28    set ht [file join $base $topic help.tcl]
29    if {[file exists $ht]} {
30	source $ht
31	return [sak::help::on::$topic]
32    }
33
34    set    help ""
35    append help \n
36    append help "    The topic \"$topic\" is not known." \n
37    append help "    The known topics are:" \n\n
38
39    append help [topics]
40
41    return $help
42}
43
44proc ::sak::help::alltopics {} {
45    # Locate the quick-help for all topics and combine it with a
46    # general header.
47
48    set    help "\n"
49    append help "    SAK - Swiss Army Knife\n\n"
50    append help "    sak is a tool to ease the work"
51    append help " of developers and release managers. Try:\n\n"
52    append help [topics]
53
54    return $help
55}
56
57proc ::sak::help::topics {} {
58    variable base
59    set help ""
60    foreach f [lsort [glob -nocomplain -directory $base */topic.txt]] {
61	append help \tsak\ help\ [get_input $f]
62    }
63    return $help
64}
65
66# ###
67
68namespace eval ::sak::help {
69    variable base [file join $::distribution support devel sak]
70}
71
72##
73# ###
74
75package provide sak::help 1.0
76