set endoptsposn [lsearch $args --] ;#first -- if data expected to contain --, then should always be called with --. e.g inspect --
set endoptsposn [lsearch $args --] ;#first -- if data expected to contain --, then should always be called with --. e.g inspect --
if {$endoptsposn >= 0} {
if {$endoptsposn >= 0} {
@ -6732,8 +6732,8 @@ namespace eval punk {
error "inspect: unknown option $k. Known options: [dict keys $defaults]. If data contains flaglike elements, consider calling with end-of-opts marker. e.g inspect --"
error "inspect: unknown option $k. Known options: [dict keys $defaults]. If data contains flaglike elements, consider calling with end-of-opts marker. e.g inspect --"
}
}
}
}
set opts [dict merge $defaults $flags]
set opts [dict merge $defaults $flags]
# -- --- --- --- ---
set label [dict get $opts -label]
set label [dict get $opts -label]
set channel [dict get $opts -channel]
set channel [dict get $opts -channel]
set showcount [dict get $opts -showcount]
set showcount [dict get $opts -showcount]
@ -6741,6 +6741,15 @@ namespace eval punk {
set label "${label}: "
set label "${label}: "
}
}
set limit [dict get $opts -limit]
set limit [dict get $opts -limit]
set opt_ansi [dict get $opts -ansi]
if {[string tolower $opt_ansi] ni [list 0 1 2 view]} {
error "inspect -ansi 0|1|2|view - received -ansi $opt_ansi"
}
if {[string tolower $opt_ansi] eq "view"} {
set opt_ansi 2
}
# -- --- --- --- ---
set more ""
set more ""
if {[llength $pipeargs] == 1} {
if {[llength $pipeargs] == 1} {
#usual case is data as a single element
#usual case is data as a single element
@ -6755,7 +6764,8 @@ namespace eval punk {
return $val
return $val
}
}
set displayval $val ;#default - may be overridden based on -limit
set displayval $val ;#default - may be overridden based on -limit
if {![catch {llength $val} llen]} {
if {$count > 1} {
#val is a list
#val is a list
if {$limit > 0 && ($limit < $llen)} {
if {$limit > 0 && ($limit < $llen)} {
set displayval [lrange $val 0 $limit-1]
set displayval [lrange $val 0 $limit-1]
@ -6786,6 +6796,11 @@ namespace eval punk {
} else {
} else {
set displaycount ""
set displaycount ""
}
}
if {$opt_ansi == 0} {
set displayval [punk::ansi::stripansi $displayval]
} elseif {$opt_ansi == 2} {
set displayval [ansistring VIEW $displayval]
}
if {![string length $more]} {
if {![string length $more]} {
puts $channel "$displaycount$label[a green bold]$displayval[a]"
puts $channel "$displaycount$label[a green bold]$displayval[a]"
} else {
} else {
@ -6868,17 +6883,49 @@ namespace eval punk {
append warningblock \n "minor warning: punk::repl::has_script_var_bug returned true! (string rep for list variable in script generated when script changed)"
append warningblock \n "minor warning: punk::repl::has_script_var_bug returned true! (string rep for list variable in script generated when script changed)"
}
}
set hidden_width_pm [punk::console::test_char_width [punk::ansi::controlstring_PM "hidden"]]