cmdr
Check-in [b5c4809789]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:cmdr::help::json, cmdr::help::tcl - Fixed handling of category with sub-categories, but no commands. Bumped to version 1.0.1.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:b5c480978951c6709197169d367937029e78b3f3
User & Date: andreask 2014-05-05 18:52:13
Context
2014-05-07
21:58
cmdr::validate (rpath) - Fixed bug in the path check. Removed bogus test for directory. This VT accepts files too. Bumped to version 1.3.1. check-in: e7ed76dd06 user: andreask tags: trunk
2014-05-05
18:52
cmdr::help::json, cmdr::help::tcl - Fixed handling of category with sub-categories, but no commands. Bumped to version 1.0.1. check-in: b5c4809789 user: andreask tags: trunk
2014-04-23
05:39
Move the p-name helper command of validate::common into the parameter class, as a convenience method. check-in: 288c34780b user: aku tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to help_json.tcl.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
..
81
82
83
84
85
86
87

88
89
90

91
92
93
94
95
96
97
...
197
198
199
200
201
202
203
204
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## CMDR - Help - JSON format. Not available by default.
## Require this package before creation a commander, so that the
## mdr::help heuristics see and automatically integrate the format.

# @@ Meta Begin
# Package cmdr::help::json 1.0
# Meta author   {Andreas Kupries}
# Meta location https://core.tcl.tk/akupries/cmdr
# Meta platform tcl
# Meta summary     Formatting help as JSON object.
# Meta description Formatting help as JSON object.
# Meta subject {command line}
# Meta require {Tcl 8.5-}
................................................................................
namespace eval ::cmdr::help::format::JSON {}

proc ::cmdr::help::format::JSON::acategory {path cmds subc} {
    set name [lindex $path end]

    # With struct::list map we could then also re-use alist.
    set commands {}

    foreach def [lsort -dict -unique [dict get $cmds $path]] {
	lassign $def cname _
	lappend commands [json::write string $cname]

    }

    set sections {}
    if {[dict exists $subc $path]} {
	# Add the sub-categories, if any.
	foreach c [lsort -dict -unique [dict get $subc $path]] {
	    lappend sections [acategory [linsert $path end $c] $cmds $subc]
................................................................................
proc ::cmdr::help::format::JSON::astring {string} {
    regsub -all -- {[ \n\t]+} $string { } string
    return [json::write string [string trim $string]]
}

# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr::help::json 1.0







|







 







>
|
|
|
>







 







|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
..
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
...
199
200
201
202
203
204
205
206
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## CMDR - Help - JSON format. Not available by default.
## Require this package before creation a commander, so that the
## mdr::help heuristics see and automatically integrate the format.

# @@ Meta Begin
# Package cmdr::help::json 1.0.1
# Meta author   {Andreas Kupries}
# Meta location https://core.tcl.tk/akupries/cmdr
# Meta platform tcl
# Meta summary     Formatting help as JSON object.
# Meta description Formatting help as JSON object.
# Meta subject {command line}
# Meta require {Tcl 8.5-}
................................................................................
namespace eval ::cmdr::help::format::JSON {}

proc ::cmdr::help::format::JSON::acategory {path cmds subc} {
    set name [lindex $path end]

    # With struct::list map we could then also re-use alist.
    set commands {}
    if {[dict exists $cmds $path]} {
	foreach def [lsort -dict -unique [dict get $cmds $path]] {
	    lassign $def cname _
	    lappend commands [json::write string $cname]
	}
    }

    set sections {}
    if {[dict exists $subc $path]} {
	# Add the sub-categories, if any.
	foreach c [lsort -dict -unique [dict get $subc $path]] {
	    lappend sections [acategory [linsert $path end $c] $cmds $subc]
................................................................................
proc ::cmdr::help::format::JSON::astring {string} {
    regsub -all -- {[ \n\t]+} $string { } string
    return [json::write string [string trim $string]]
}

# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr::help::json 1.0.1

Changes to help_tcl.tcl.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
..
77
78
79
80
81
82
83

84
85

86
87
88
89
90
91
92
...
176
177
178
179
180
181
182
183
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## CMDR - Help - TCL format. Not available by default.
## Require this package before creation a commander, so that the
## mdr::help heuristics see and automatically integrate the format.

# @@ Meta Begin
# Package cmdr::help::tcl 1.0
# Meta author   {Andreas Kupries}
# Meta location https://core.tcl.tk/akupries/cmdr
# Meta platform tcl
# Meta summary     Formatting help as TCL data structure (nested dict/list).
# Meta description Formatting help as TCL data structure (nested dict/list).
# Meta subject {command line}
# Meta require {Tcl 8.5-}
................................................................................
namespace eval ::cmdr::help::format::TCL {}

proc ::cmdr::help::format::TCL::acategory {path cmds subc} {
    set name [lindex $path end]

    # With struct::list map we could then also re-use alist.
    set commands {}

    foreach def [lsort -dict -unique [dict get $cmds $path]] {
	lappend commands [lindex $def 0]

    }

    set sections {}
    if {[dict exists $subc $path]} {
	# Add the sub-categories, if any.
	foreach c [lsort -dict -unique [dict get $subc $path]] {
	    lappend sections [acategory [linsert $path end $c] $cmds $subc]
................................................................................
proc ::cmdr::help::format::TCL::astring {string} {
    regsub -all -- {[ \n\t]+} $string { } string
    return [string trim $string]
}

# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr::help::tcl 1.0







|







 







>
|
|
>







 







|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
..
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
...
178
179
180
181
182
183
184
185
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## CMDR - Help - TCL format. Not available by default.
## Require this package before creation a commander, so that the
## mdr::help heuristics see and automatically integrate the format.

# @@ Meta Begin
# Package cmdr::help::tcl 1.0.1
# Meta author   {Andreas Kupries}
# Meta location https://core.tcl.tk/akupries/cmdr
# Meta platform tcl
# Meta summary     Formatting help as TCL data structure (nested dict/list).
# Meta description Formatting help as TCL data structure (nested dict/list).
# Meta subject {command line}
# Meta require {Tcl 8.5-}
................................................................................
namespace eval ::cmdr::help::format::TCL {}

proc ::cmdr::help::format::TCL::acategory {path cmds subc} {
    set name [lindex $path end]

    # With struct::list map we could then also re-use alist.
    set commands {}
    if {[dict exists $cmds $path]} {
	foreach def [lsort -dict -unique [dict get $cmds $path]] {
	    lappend commands [lindex $def 0]
	}
    }

    set sections {}
    if {[dict exists $subc $path]} {
	# Add the sub-categories, if any.
	foreach c [lsort -dict -unique [dict get $subc $path]] {
	    lappend sections [acategory [linsert $path end $c] $cmds $subc]
................................................................................
proc ::cmdr::help::format::TCL::astring {string} {
    regsub -all -- {[ \n\t]+} $string { } string
    return [string trim $string]
}

# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr::help::tcl 1.0.1