Browse Source

vfs update for last changes

master
Julian Noble 2 months ago
parent
commit
3fd56394a3
  1. 68
      src/vfs/_vfscommon/modules/punk-0.1.tm
  2. 35
      src/vfs/_vfscommon/modules/punk/config-0.1.tm
  3. 7
      src/vfs/_vfscommon/modules/punk/repl-0.1.tm
  4. BIN
      src/vfs/_vfscommon/modules/test/tomlish-1.1.1.tm
  5. 1702
      src/vfs/_vfscommon/modules/tomlish-1.1.1.tm

68
src/vfs/_vfscommon/modules/punk-0.1.tm

@ -295,16 +295,59 @@ namespace eval punk {
return [twapi::new_uuid] return [twapi::new_uuid]
} }
} }
proc ::punk::var {varname {= {}} args} {
#get last command result that was run through the repl
proc ::punk::get_runchunk {args} {
set argd [punk::args::get_dict {
*opts
-1 -optional 1 -type none
-2 -optional 1 -type none
*values -min 0 -max 0
} $args]
#todo - make this command run without truncating previous runchunks
set runchunks [tsv::array names repl runchunks-*]
set sortlist [list]
foreach cname $runchunks {
set num [lindex [split $cname -] 1]
lappend sortlist [list $num $cname]
}
set sorted [lsort -index 0 -integer $sortlist]
set chunkname [lindex $sorted end-1 1]
set runlist [tsv::get repl $chunkname]
#puts stderr "--$runlist"
if {![llength $runlist]} {
return ""
} else {
return [lindex [lsearch -inline -index 0 $runlist result] 1]
}
}
interp alias {} _ {} ::punk::get_runchunk
proc ::punk::var {varname {= _=.=_} args} {
upvar $varname the_var upvar $varname the_var
if {${=} == "="} { switch -exact -- ${=} {
if {[llength $args] > 1} { = {
set the_var [uplevel 1 $args] if {[llength $args] > 1} {
} else { set the_var $args
set the_var [lindex $args 0] } else {
set the_var [lindex $args 0]
}
}
.= {
if {[llength $args] > 1} {
set the_var [uplevel 1 $args]
} else {
set the_var [uplevel 1 [lindex $args 0]]
}
}
_=.=_ {
set the_var
}
default {
set the_var [list ${=} {*}$args]
} }
} else {
set the_var
} }
} }
proc src {args} { proc src {args} {
@ -7302,6 +7345,15 @@ namespace eval punk {
set usetable 1 set usetable 1
if {$usetable} { if {$usetable} {
set t [textblock::class::table new -show_hseps 0 -show_header 1 -ansiborder_header [a+ web-green]] set t [textblock::class::table new -show_hseps 0 -show_header 1 -ansiborder_header [a+ web-green]]
if {"windows" eq $::tcl_platform(platform)} {
#If any env vars have been set to empty string - this is considered a deletion of the variable on windows.
#The Tcl ::env array is linked to the underlying process view of the environment
#- but info exists ::env(var) can misreport as true if it has been deleted by setting to empty string rather than using unset.
#an 'array get' will resynchronise.
#Even if an env variable didn't exist before - setting it to empty string can get it to this inconsistent state.
array get ::env
}
#do an array read on ::env
foreach {v vinfo} $punkenv_config { foreach {v vinfo} $punkenv_config {
if {[info exists ::env($v)]} { if {[info exists ::env($v)]} {
set c2 [set ::env($v)] set c2 [set ::env($v)]

35
src/vfs/_vfscommon/modules/punk/config-0.1.tm

@ -333,17 +333,30 @@ tcl::namespace::eval punk::config {
error "No such global configuration item '$varname' found in startup config" error "No such global configuration item '$varname' found in startup config"
} }
proc get {whichconfig} { proc get {whichconfig {globfor *}} {
variable startup variable startup
variable running variable running
switch -- $whichconfig { switch -- $whichconfig {
config - startup - startup-config - startup-configuration { config - startup - startup-config - startup-configuration {
#show *startup* config - different behaviour may be confusing to those used to router startup and running configs #show *startup* config - different behaviour may be confusing to those used to router startup and running configs
return $startup set configdata $startup
} }
running - running-config - running-configuration { running - running-config - running-configuration {
return $running set configdata $running
} }
default {
error "Unknown config name '$whichconfig' - try startup or running"
}
}
if {$globfor eq "*"} {
return $configdata
} else {
set keys [dict keys $configdata [string tolower $globfor]]
set filtered [dict create]
foreach k $keys {
dict set filtered $k [dict get $configdata $k]
}
return $filtered
} }
} }
@ -355,20 +368,10 @@ tcl::namespace::eval punk::config {
} }
proc show {whichconfig} { proc show {whichconfig {globfor *}} {
#todo - tables for console #todo - tables for console
variable startup set configdata [punk::config::get $whichconfig $globfor]
variable running return [punk::lib::showdict $configdata]
switch -- $whichconfig {
config - startup - startup-config - startup-configuration {
#show *startup* config - different behaviour may be confusing to those used to router startup and running configs
return [punk::lib::showdict $startup]
}
running - running-config - running-configuration {
return [punk::lib::showdict $running]
}
}
} }
#e.g #e.g

7
src/vfs/_vfscommon/modules/punk/repl-0.1.tm

@ -1992,6 +1992,9 @@ proc repl::repl_process_data {inputchan chunktype chunk stdinlines prompt_config
set repl_runid [tsv::incr repl runid] set repl_runid [tsv::incr repl runid]
tsv::set repl runchunks-$repl_runid [list] ;#last_run_display tsv::set repl runchunks-$repl_runid [list] ;#last_run_display
catch {
tsv::unset repl runchunks-[expr {$repl_runid - 10}]
}
#set ::repl::last_unknown "" #set ::repl::last_unknown ""
tsv::set repl last_unknown "" tsv::set repl last_unknown ""
@ -2260,6 +2263,10 @@ proc repl::repl_process_data {inputchan chunktype chunk stdinlines prompt_config
#we have copied rawresult using append with empty string - so our string interaction with result var here shouldn't affect the returned value #we have copied rawresult using append with empty string - so our string interaction with result var here shouldn't affect the returned value
#empty-string result handled in other branch #empty-string result handled in other branch
if {![tsv::llength repl runchunks-$repl_runid]} {
#write back to tsv var for use by punk::get_runchunks (underscore command)
tsv::set repl runchunks-$repl_runid [list [list result $result]]
}
set flat [string map [list \r\n "" \n ""] $result] set flat [string map [list \r\n "" \n ""] $result]
if {[string length $flat] == [string length $result]} { if {[string length $flat] == [string length $result]} {
#no line-endings in data #no line-endings in data

BIN
src/vfs/_vfscommon/modules/test/tomlish-1.1.1.tm

Binary file not shown.

1702
src/vfs/_vfscommon/modules/tomlish-1.1.1.tm

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save