Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | cmdr::help - Extended the backend to invoke a pager if the help is too high for the terminal. Lots of things (not terminal, no support in linenoise, no pager) will disable this. Bumped version to 1.3. |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
e15928b8301b1afb848fa63e6c241805 |
User & Date: | andreask 2014-06-03 00:16:28.712 |
Context
2014-06-03
| ||
00:19 | Fix stupid typo in definition of the Pager support command. check-in: d4b3af213d user: andreask tags: trunk | |
00:16 | cmdr::help - Extended the backend to invoke a pager if the help is too high for the terminal. Lots of things (not terminal, no support in linenoise, no pager) will disable this. Bumped version to 1.3. check-in: e15928b830 user: andreask tags: trunk | |
2014-05-28
| ||
23:33 | cmdr::actor, cmdr::officer - Fix bug introduced with revision [7ab77ead21]. The option handling added to "actor::set" in that revision means that the command "my set *command* ..." storing the actual command line (i.e. user information) can break, trying to interpret application specific option information as something for the internal command. Fixed by adding "--" to "actor::set"s option handling, and using it for the breakable command to force interpretation of the user data as such. check-in: cd7539eb28 user: andreask tags: trunk | |
Changes
Changes to help.tcl.
︙ | ︙ | |||
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | package require Tcl 8.5 package require debug package require debug::caller package require lambda package require linenoise package require textutil::adjust package require cmdr::util # # ## ### ##### ######## ############# ##################### debug define cmdr/help debug level cmdr/help debug prefix cmdr/help {[debug caller] | } # # ## ### ##### ######## ############# ##################### ## Definition namespace eval ::cmdr { namespace export help namespace ensemble create } namespace eval ::cmdr::help { namespace export query format auto namespace ensemble create } # # ## ### ##### ######## ############# ##################### proc ::cmdr::help::query {actor words} { debug.cmdr/help {} # Resolve chain of words (command name path) to the actor | > > > | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | package require Tcl 8.5 package require debug package require debug::caller package require lambda package require linenoise package require textutil::adjust package require cmdr::util package require cmdr::tty # # ## ### ##### ######## ############# ##################### debug define cmdr/help debug level cmdr/help debug prefix cmdr/help {[debug caller] | } # # ## ### ##### ######## ############# ##################### ## Definition namespace eval ::cmdr { namespace export help namespace ensemble create } namespace eval ::cmdr::help { namespace export query format auto namespace ensemble create namespace import ::cmdr::tty } # # ## ### ##### ######## ############# ##################### proc ::cmdr::help::query {actor words} { debug.cmdr/help {} # Resolve chain of words (command name path) to the actor |
︙ | ︙ | |||
150 151 152 153 154 155 156 | set format full } } else { set format by-category } } | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | set format full } } else { set format by-category } } set text [format $format \ [$actor root] \ $width \ [cmdr util dictsort \ [query $actor $words]]] # Determine how to show the help, in a pager, or not ? if {![tty stdout]} { # Not a terminal, no pager possible. # This is also the case handling windows. puts $text } else { # Terminal if {[catch { set height [linenoise lines] }]} { # Unable to get the terminal height. # Don't do paging. puts $text } else { # Compare the help's height to the terminal. set lines [llength [split $text \n]] if {$lines <= $height} { # The help fits fully into the terminal, no pager # needed. puts $text } else { # The help is too high, and does not fit into the # current terminal. set pager [Pager] if {![llength $pager]} { # We found no pager, and give up on trying to use # one. puts $text } else { # We needed and have a pager, run it with the help. # as input. set pipe [open "|$pager" w] puts $pipe $text # This waits until the pager exits. close $pipe } } } } return } proc ::cmdr::help::format::Pager {} { global env if {[info exists env(PAGER)]} { lappend pager $env(PAGER) } lappend pager less lappend pager more foreach p $pager { set cmd [auto_execok $p] if {[llength $cmd]} break } return $cmd } # # ## ### ##### ######## ############# ##################### namespace eval ::cmdr::help::format { namespace export full list short by-category namespace ensemble create } |
︙ | ︙ | |||
522 523 524 525 526 527 528 | return $categories } # # ## ### ##### ######## ############# ##################### ## Ready | | | 581 582 583 584 585 586 587 588 | return $categories } # # ## ### ##### ######## ############# ##################### ## Ready package provide cmdr::help 1.3 |