Rev 315 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
352 | jag | 1 | if 0 { |
1 | - | 2 | /* |
3 | * This file is part of din. |
||
4 | * |
||
352 | jag | 5 | * din is copyright (c) 2006 - 2017 S Jagannathan <jag@dinisnoise.org> |
1 | - | 6 | * For more information, please visit http://dinisnoise.org |
7 | */ |
||
8 | command help display |
||
9 | } |
||
10 | |||
11 | proc help {{cmd ""}} { |
||
12 | |||
13 | global color |
||
14 | |||
15 | set-var fold_console 0 |
||
16 | |||
352 | jag | 17 | global user |
18 | if {[file exists $user/$cmd.help.tcl] == 0} { |
||
1 | - | 19 | if {$cmd ne ""} { |
20 | eval $color(error) |
||
21 | echo "$cmd: not found." |
||
22 | } |
||
23 | eval $color(header) |
||
24 | echo "Available commands are:" |
||
25 | eval $color(text) |
||
26 | nago [lsort [lsuserdir help.tcl]] 4 |
||
27 | eval $color(header) |
||
28 | echo "Type help <command_name> for help on a command." |
||
29 | return |
||
30 | } |
||
31 | |||
352 | jag | 32 | source $user/$cmd.help.tcl |
1 | - | 33 | set headers {NAME: {SHORT NAME:} PURPOSE: {HOW TO USE:} NOTES: EXAMPLES:} |
34 | set keys {name short purpose invoke help examples} |
||
35 | for {set i 0; set j [llength $keys]} {$i < $j} {incr i} { |
||
36 | set text [lindex [array get $cmd [lindex $keys $i]] 1] |
||
37 | if {[llength $text] > 0} { |
||
38 | eval $color(header) |
||
39 | echo [lindex $headers $i] |
||
40 | eval $color(text) |
||
41 | foreach l [split $text \n] {echo $l} |
||
42 | } |
||
43 | } |
||
44 | |||
45 | } |
||
46 | |||
47 | proc nago {target n} { |
||
48 | set j 0 |
||
49 | foreach i [lrange $target 0 end-1] { |
||
50 | if {$j < $n} {incr j} else { |
||
51 | echo $out |
||
52 | unset out |
||
53 | set j 0 |
||
54 | } |
||
55 | append out " $i, "; |
||
56 | } |
||
57 | |||
58 | append out "and [lindex $target end]" |
||
59 | echo $out |
||
60 | |||
61 | } |