Browse Source

default sort order for namespaces and directory listings - natsort/dictionary

master
Julian Noble 4 months ago
parent
commit
2862a05cb9
  1. 19
      src/bootsupport/modules/punk/args/tclcore-0.1.0.tm
  2. 6
      src/bootsupport/modules/punk/nav/fs-0.1.0.tm
  3. 41
      src/bootsupport/modules/punk/ns-0.1.0.tm
  4. 68
      src/bootsupport/modules/punk/path-0.1.0.tm
  5. 19
      src/modules/punk/args/tclcore-999999.0a1.0.tm
  6. 6
      src/modules/punk/nav/fs-999999.0a1.0.tm
  7. 41
      src/modules/punk/ns-999999.0a1.0.tm
  8. 68
      src/modules/punk/path-999999.0a1.0.tm
  9. 19
      src/project_layouts/custom/_project/punk.project-0.1/src/bootsupport/modules/punk/args/tclcore-0.1.0.tm
  10. 6
      src/project_layouts/custom/_project/punk.project-0.1/src/bootsupport/modules/punk/nav/fs-0.1.0.tm
  11. 41
      src/project_layouts/custom/_project/punk.project-0.1/src/bootsupport/modules/punk/ns-0.1.0.tm
  12. 68
      src/project_layouts/custom/_project/punk.project-0.1/src/bootsupport/modules/punk/path-0.1.0.tm
  13. 19
      src/project_layouts/custom/_project/punk.shell-0.1/src/bootsupport/modules/punk/args/tclcore-0.1.0.tm
  14. 6
      src/project_layouts/custom/_project/punk.shell-0.1/src/bootsupport/modules/punk/nav/fs-0.1.0.tm
  15. 41
      src/project_layouts/custom/_project/punk.shell-0.1/src/bootsupport/modules/punk/ns-0.1.0.tm
  16. 68
      src/project_layouts/custom/_project/punk.shell-0.1/src/bootsupport/modules/punk/path-0.1.0.tm
  17. 19
      src/vfs/_vfscommon.vfs/modules/punk/args/tclcore-0.1.0.tm
  18. 6
      src/vfs/_vfscommon.vfs/modules/punk/nav/fs-0.1.0.tm
  19. 41
      src/vfs/_vfscommon.vfs/modules/punk/ns-0.1.0.tm
  20. 68
      src/vfs/_vfscommon.vfs/modules/punk/path-0.1.0.tm

19
src/bootsupport/modules/punk/args/tclcore-0.1.0.tm

@ -1648,6 +1648,25 @@ tcl::namespace::eval punk::args::tclcore {
}
# -- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
lappend PUNKARGS [list {
@id -id ::tcl::namespace::children
@cmd -name "Built-in: tcl::namespace::children"\
-summary\
"list child namespaces"\
-help\
"Returns a list of all child namespaces that belong to the namespace namespace.
If namespace is not specified, then the children are returned for the current
namespace. This command returns fully-qualified names, which start with a double
colon (::). If the optional pattern is given, then this command returns only the
names that match the glob-style pattern. The actual pattern used is determined as
follows: a pattern that starts with double colon (::) is used directly, otherwise
the namespace namespace (or the fully-qualified name of the current namespace) is
prepended onto the pattern."
@values
namespace -optional 1
pattern -optional 1
} "@doc -name Manpage: -url [manpage_tcl namespace]" ]
lappend PUNKARGS [list {
@id -id ::tcl::namespace::origin
@cmd -name "Built-in: tcl::namespace::origin" -help\

6
src/bootsupport/modules/punk/nav/fs-0.1.0.tm

@ -948,7 +948,7 @@ tcl::namespace::eval punk::nav::fs {
set flaggedhidden [punk::lib::lunique_unordered $flaggedhidden]
}
set dirs [lsort $dirs] ;#todo - natsort
set dirs [lsort -dictionary $dirs] ;#todo - natsort
@ -965,10 +965,10 @@ tcl::namespace::eval punk::nav::fs {
#Note - the sort by index would convert an empty filesizes list to a list of empty strings - one for each entry in files
#We want to preserve the empty list if that's what the dirlisting mechanism returned (presumably because -with_sizes was 0 or explicitly excluded files)
if {[llength $filesizes] == 0} {
set sorted_files [lsort $files]
set sorted_files [lsort -dictionary $files]
set sorted_filesizes [list]
} else {
set sortorder [lsort -indices $files]
set sortorder [lsort -indices -dictionary $files]
set sorted_files [list]
set sorted_filesizes [list]
foreach i $sortorder {

41
src/bootsupport/modules/punk/ns-0.1.0.tm

@ -311,7 +311,17 @@ tcl::namespace::eval punk::ns {
}
proc nschildren {ns} {
punk::args::define {
@id -id ::punk::ns::nschildren
@cmd -name punk::ns::nschildren
@opts
-sort -default "natural" -choices {none natural ascii dictionary}
ns
}
proc nschildren {args} {
set argd [punk::args::parse $args withid ::punk::ns::nschildren]
set opt_sort [dict get $argd opts -sort]
set ns [dict get $argd values ns]
set parts [nsparts $ns]
if {[lindex $parts 0] ne ""} {
#relative
@ -329,7 +339,21 @@ tcl::namespace::eval punk::ns {
#set nslist [nseval $parent [list ::namespace children $tail]]
#set nslist [tcl::namespace::eval $parent [list ::tcl::namespace::children $tail]]
set nslist [nseval_ifexists $parent [list ::tcl::namespace::children $tail]]
return [lsort $nslist]
switch -- $opt_sort {
ascii {
return [lsort $nslist]
}
dictionary {
return [lsort -dictionary $nslist]
}
natural {
package require natsort
return [natsort::sort $nslist]
}
default {
return $nslist
}
}
}
#Note nsjoin,nsjoinall,nsprefix,nstail are string functions that don't care about namespaces in existence.
@ -1249,7 +1273,7 @@ tcl::namespace::eval punk::ns {
append path_text \n " cmds: $cmds"
}
} else {
#todo - change to display in column order to be same as main command listing
#todo - change to display in column order - so as to be same as main command listing
set parentcommands [dict get $nsdict commands]
dict for {k v} $nspathdict {
set rawpathcommands [dict get $v commands]
@ -1404,7 +1428,7 @@ tcl::namespace::eval punk::ns {
if {$allbelow == 0 && !$has_globchars} {
set allchildren [list]
} else {
set allchildren [nschildren $ch] ; #sorted, only returns 1 level deeper
set allchildren [nschildren -sort none $ch] ; #only returns 1 level deeper. leave sorting til after filtering
}
#nscommands returns exactly one line per entry + a trailing newline. If there is an empty line other than at the end - that is because there is a command named as the empty string.
@ -1784,10 +1808,17 @@ tcl::namespace::eval punk::ns {
}
}
}
#catch {package require natsort}
#if {[package provide natsort] ne ""} {
# set childtailmatches [natsort::sort $childtailmatches]
#} else {
# set childtailmatches [lsort $childtailmatches]
#}
set childtailmatches [lsort -dictionary $childtailmatches]
set nsdict [dict create\
location $location\
children [lsort $childtailmatches]\
children $childtailmatches\
commands $commands\
procs $procs\
exported $exported\

68
src/bootsupport/modules/punk/path-0.1.0.tm

@ -686,6 +686,7 @@ namespace eval punk::path {
-directory -type directory -help\
"folder in which to begin recursive scan for files."
-call-depth-internal -default 0 -type integer
-sort -type any -default natural -choices {none ascii dictionary natural}
-antiglob_paths -default {} -help\
"list of path patterns to exclude
may include * and ** path segments e.g
@ -718,6 +719,7 @@ namespace eval punk::path {
lassign [dict values $argd] leaders opts values received
set tailglobs [dict get $values tailglobs]
# -- --- --- --- --- --- ---
set opt_sort [dict get $opts -sort]
set opt_antiglob_paths [dict get $opts -antiglob_paths]
set opt_antiglob_files [dict get $opts -antiglob_files]
set CALLDEPTH [dict get $opts -call-depth-internal]
@ -726,6 +728,9 @@ namespace eval punk::path {
set files [list]
if {$CALLDEPTH == 0} {
if {$opt_sort eq "natural"} {
package require natsort
}
#set opts [dict merge $opts [list -directory $opt_dir]]
if {![dict exists $received -directory]} {
set opt_dir [pwd]
@ -779,7 +784,20 @@ namespace eval punk::path {
} else {
set retained $matches
}
set dirfiles [lsort $retained]
switch -- $opt_sort {
ascii {
set dirfiles [lsort $retained]
}
dictionary {
set dirfiles [lsort -dictionary $retained]
}
natural {
set dirfiles [natsort::sort $retained]
}
default {
set dirfiles $retained
}
}
}
lappend files {*}$dirfiles
@ -787,7 +805,7 @@ namespace eval punk::path {
puts stderr "treefilenames error while listing subdirs in dir $opt_dir\n $dirdirs"
set dirdirs [list]
}
set okdirs [list]
foreach dir $dirdirs {
set skip 0
foreach anti $opt_antiglob_paths {
@ -796,11 +814,29 @@ namespace eval punk::path {
break
}
}
if {$skip} {
continue
if {!$skip} {
lappend okdirs $dir
}
}
if {[llength $okdirs]} {
switch -- $opt_sort {
ascii {
set finaldirs [lsort $okdirs]
}
dictionary {
set finaldirs [lsort -dictionary $okdirs]
}
natural {
set finaldirs [natsort::sort $okdirs]
}
default {
set finaldirs $okdirs
}
}
foreach dir $finaldirs {
set nextopts [dict merge $opts [list -directory $dir -call-depth-internal [incr CALLDEPTH]]]
lappend files {*}[treefilenames {*}$nextopts {*}$tailglobs]
}
set nextopts [dict merge $opts [list -directory $dir -call-depth-internal [incr CALLDEPTH]]]
lappend files {*}[treefilenames {*}$nextopts {*}$tailglobs]
}
return $files
}
@ -813,12 +849,16 @@ namespace eval punk::path {
# -- --- --- --- --- --- ---
set opt_antiglob_paths [dict get $opts -antiglob_paths]
set opt_antiglob_files [dict get $opts -antiglob_files]
set opt_sort [dict get $opts -sort]
set CALLDEPTH [dict get $opts -call-depth-internal]
# -- --- --- --- --- --- ---
# -- --- --- --- --- --- ---
set files [list]
if {$CALLDEPTH == 0} {
if {$opt_sort eq "natural"} {
package require natsort
}
#set opts [dict merge $opts [list -directory $opt_dir]]
if {![dict exists $received -directory]} {
set opt_dir [pwd]
@ -934,7 +974,21 @@ namespace eval punk::path {
}
}
}
return $filelist
switch -- $opt_sort {
ascii {
set finalfilelist [lsort $filelist]
}
dictionary {
set finalfilelist [lsort -dictionary $filelist]
}
natural {
set finalfilelist [natsort::sort $filelist]
}
default {
set finalfilelist $filelist
}
}
return $finalfilelist
}
#maint warning - also in punkcheck

19
src/modules/punk/args/tclcore-999999.0a1.0.tm

@ -1648,6 +1648,25 @@ tcl::namespace::eval punk::args::tclcore {
}
# -- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
lappend PUNKARGS [list {
@id -id ::tcl::namespace::children
@cmd -name "Built-in: tcl::namespace::children"\
-summary\
"list child namespaces"\
-help\
"Returns a list of all child namespaces that belong to the namespace namespace.
If namespace is not specified, then the children are returned for the current
namespace. This command returns fully-qualified names, which start with a double
colon (::). If the optional pattern is given, then this command returns only the
names that match the glob-style pattern. The actual pattern used is determined as
follows: a pattern that starts with double colon (::) is used directly, otherwise
the namespace namespace (or the fully-qualified name of the current namespace) is
prepended onto the pattern."
@values
namespace -optional 1
pattern -optional 1
} "@doc -name Manpage: -url [manpage_tcl namespace]" ]
lappend PUNKARGS [list {
@id -id ::tcl::namespace::origin
@cmd -name "Built-in: tcl::namespace::origin" -help\

6
src/modules/punk/nav/fs-999999.0a1.0.tm

@ -948,7 +948,7 @@ tcl::namespace::eval punk::nav::fs {
set flaggedhidden [punk::lib::lunique_unordered $flaggedhidden]
}
set dirs [lsort $dirs] ;#todo - natsort
set dirs [lsort -dictionary $dirs] ;#todo - natsort
@ -965,10 +965,10 @@ tcl::namespace::eval punk::nav::fs {
#Note - the sort by index would convert an empty filesizes list to a list of empty strings - one for each entry in files
#We want to preserve the empty list if that's what the dirlisting mechanism returned (presumably because -with_sizes was 0 or explicitly excluded files)
if {[llength $filesizes] == 0} {
set sorted_files [lsort $files]
set sorted_files [lsort -dictionary $files]
set sorted_filesizes [list]
} else {
set sortorder [lsort -indices $files]
set sortorder [lsort -indices -dictionary $files]
set sorted_files [list]
set sorted_filesizes [list]
foreach i $sortorder {

41
src/modules/punk/ns-999999.0a1.0.tm

@ -311,7 +311,17 @@ tcl::namespace::eval punk::ns {
}
proc nschildren {ns} {
punk::args::define {
@id -id ::punk::ns::nschildren
@cmd -name punk::ns::nschildren
@opts
-sort -default "natural" -choices {none natural ascii dictionary}
ns
}
proc nschildren {args} {
set argd [punk::args::parse $args withid ::punk::ns::nschildren]
set opt_sort [dict get $argd opts -sort]
set ns [dict get $argd values ns]
set parts [nsparts $ns]
if {[lindex $parts 0] ne ""} {
#relative
@ -329,7 +339,21 @@ tcl::namespace::eval punk::ns {
#set nslist [nseval $parent [list ::namespace children $tail]]
#set nslist [tcl::namespace::eval $parent [list ::tcl::namespace::children $tail]]
set nslist [nseval_ifexists $parent [list ::tcl::namespace::children $tail]]
return [lsort $nslist]
switch -- $opt_sort {
ascii {
return [lsort $nslist]
}
dictionary {
return [lsort -dictionary $nslist]
}
natural {
package require natsort
return [natsort::sort $nslist]
}
default {
return $nslist
}
}
}
#Note nsjoin,nsjoinall,nsprefix,nstail are string functions that don't care about namespaces in existence.
@ -1249,7 +1273,7 @@ tcl::namespace::eval punk::ns {
append path_text \n " cmds: $cmds"
}
} else {
#todo - change to display in column order to be same as main command listing
#todo - change to display in column order - so as to be same as main command listing
set parentcommands [dict get $nsdict commands]
dict for {k v} $nspathdict {
set rawpathcommands [dict get $v commands]
@ -1404,7 +1428,7 @@ tcl::namespace::eval punk::ns {
if {$allbelow == 0 && !$has_globchars} {
set allchildren [list]
} else {
set allchildren [nschildren $ch] ; #sorted, only returns 1 level deeper
set allchildren [nschildren -sort none $ch] ; #only returns 1 level deeper. leave sorting til after filtering
}
#nscommands returns exactly one line per entry + a trailing newline. If there is an empty line other than at the end - that is because there is a command named as the empty string.
@ -1784,10 +1808,17 @@ tcl::namespace::eval punk::ns {
}
}
}
#catch {package require natsort}
#if {[package provide natsort] ne ""} {
# set childtailmatches [natsort::sort $childtailmatches]
#} else {
# set childtailmatches [lsort $childtailmatches]
#}
set childtailmatches [lsort -dictionary $childtailmatches]
set nsdict [dict create\
location $location\
children [lsort $childtailmatches]\
children $childtailmatches\
commands $commands\
procs $procs\
exported $exported\

68
src/modules/punk/path-999999.0a1.0.tm

@ -686,6 +686,7 @@ namespace eval punk::path {
-directory -type directory -help\
"folder in which to begin recursive scan for files."
-call-depth-internal -default 0 -type integer
-sort -type any -default natural -choices {none ascii dictionary natural}
-antiglob_paths -default {} -help\
"list of path patterns to exclude
may include * and ** path segments e.g
@ -718,6 +719,7 @@ namespace eval punk::path {
lassign [dict values $argd] leaders opts values received
set tailglobs [dict get $values tailglobs]
# -- --- --- --- --- --- ---
set opt_sort [dict get $opts -sort]
set opt_antiglob_paths [dict get $opts -antiglob_paths]
set opt_antiglob_files [dict get $opts -antiglob_files]
set CALLDEPTH [dict get $opts -call-depth-internal]
@ -726,6 +728,9 @@ namespace eval punk::path {
set files [list]
if {$CALLDEPTH == 0} {
if {$opt_sort eq "natural"} {
package require natsort
}
#set opts [dict merge $opts [list -directory $opt_dir]]
if {![dict exists $received -directory]} {
set opt_dir [pwd]
@ -779,7 +784,20 @@ namespace eval punk::path {
} else {
set retained $matches
}
set dirfiles [lsort $retained]
switch -- $opt_sort {
ascii {
set dirfiles [lsort $retained]
}
dictionary {
set dirfiles [lsort -dictionary $retained]
}
natural {
set dirfiles [natsort::sort $retained]
}
default {
set dirfiles $retained
}
}
}
lappend files {*}$dirfiles
@ -787,7 +805,7 @@ namespace eval punk::path {
puts stderr "treefilenames error while listing subdirs in dir $opt_dir\n $dirdirs"
set dirdirs [list]
}
set okdirs [list]
foreach dir $dirdirs {
set skip 0
foreach anti $opt_antiglob_paths {
@ -796,11 +814,29 @@ namespace eval punk::path {
break
}
}
if {$skip} {
continue
if {!$skip} {
lappend okdirs $dir
}
}
if {[llength $okdirs]} {
switch -- $opt_sort {
ascii {
set finaldirs [lsort $okdirs]
}
dictionary {
set finaldirs [lsort -dictionary $okdirs]
}
natural {
set finaldirs [natsort::sort $okdirs]
}
default {
set finaldirs $okdirs
}
}
foreach dir $finaldirs {
set nextopts [dict merge $opts [list -directory $dir -call-depth-internal [incr CALLDEPTH]]]
lappend files {*}[treefilenames {*}$nextopts {*}$tailglobs]
}
set nextopts [dict merge $opts [list -directory $dir -call-depth-internal [incr CALLDEPTH]]]
lappend files {*}[treefilenames {*}$nextopts {*}$tailglobs]
}
return $files
}
@ -813,12 +849,16 @@ namespace eval punk::path {
# -- --- --- --- --- --- ---
set opt_antiglob_paths [dict get $opts -antiglob_paths]
set opt_antiglob_files [dict get $opts -antiglob_files]
set opt_sort [dict get $opts -sort]
set CALLDEPTH [dict get $opts -call-depth-internal]
# -- --- --- --- --- --- ---
# -- --- --- --- --- --- ---
set files [list]
if {$CALLDEPTH == 0} {
if {$opt_sort eq "natural"} {
package require natsort
}
#set opts [dict merge $opts [list -directory $opt_dir]]
if {![dict exists $received -directory]} {
set opt_dir [pwd]
@ -934,7 +974,21 @@ namespace eval punk::path {
}
}
}
return $filelist
switch -- $opt_sort {
ascii {
set finalfilelist [lsort $filelist]
}
dictionary {
set finalfilelist [lsort -dictionary $filelist]
}
natural {
set finalfilelist [natsort::sort $filelist]
}
default {
set finalfilelist $filelist
}
}
return $finalfilelist
}
#maint warning - also in punkcheck

19
src/project_layouts/custom/_project/punk.project-0.1/src/bootsupport/modules/punk/args/tclcore-0.1.0.tm

@ -1648,6 +1648,25 @@ tcl::namespace::eval punk::args::tclcore {
}
# -- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
lappend PUNKARGS [list {
@id -id ::tcl::namespace::children
@cmd -name "Built-in: tcl::namespace::children"\
-summary\
"list child namespaces"\
-help\
"Returns a list of all child namespaces that belong to the namespace namespace.
If namespace is not specified, then the children are returned for the current
namespace. This command returns fully-qualified names, which start with a double
colon (::). If the optional pattern is given, then this command returns only the
names that match the glob-style pattern. The actual pattern used is determined as
follows: a pattern that starts with double colon (::) is used directly, otherwise
the namespace namespace (or the fully-qualified name of the current namespace) is
prepended onto the pattern."
@values
namespace -optional 1
pattern -optional 1
} "@doc -name Manpage: -url [manpage_tcl namespace]" ]
lappend PUNKARGS [list {
@id -id ::tcl::namespace::origin
@cmd -name "Built-in: tcl::namespace::origin" -help\

6
src/project_layouts/custom/_project/punk.project-0.1/src/bootsupport/modules/punk/nav/fs-0.1.0.tm

@ -948,7 +948,7 @@ tcl::namespace::eval punk::nav::fs {
set flaggedhidden [punk::lib::lunique_unordered $flaggedhidden]
}
set dirs [lsort $dirs] ;#todo - natsort
set dirs [lsort -dictionary $dirs] ;#todo - natsort
@ -965,10 +965,10 @@ tcl::namespace::eval punk::nav::fs {
#Note - the sort by index would convert an empty filesizes list to a list of empty strings - one for each entry in files
#We want to preserve the empty list if that's what the dirlisting mechanism returned (presumably because -with_sizes was 0 or explicitly excluded files)
if {[llength $filesizes] == 0} {
set sorted_files [lsort $files]
set sorted_files [lsort -dictionary $files]
set sorted_filesizes [list]
} else {
set sortorder [lsort -indices $files]
set sortorder [lsort -indices -dictionary $files]
set sorted_files [list]
set sorted_filesizes [list]
foreach i $sortorder {

41
src/project_layouts/custom/_project/punk.project-0.1/src/bootsupport/modules/punk/ns-0.1.0.tm

@ -311,7 +311,17 @@ tcl::namespace::eval punk::ns {
}
proc nschildren {ns} {
punk::args::define {
@id -id ::punk::ns::nschildren
@cmd -name punk::ns::nschildren
@opts
-sort -default "natural" -choices {none natural ascii dictionary}
ns
}
proc nschildren {args} {
set argd [punk::args::parse $args withid ::punk::ns::nschildren]
set opt_sort [dict get $argd opts -sort]
set ns [dict get $argd values ns]
set parts [nsparts $ns]
if {[lindex $parts 0] ne ""} {
#relative
@ -329,7 +339,21 @@ tcl::namespace::eval punk::ns {
#set nslist [nseval $parent [list ::namespace children $tail]]
#set nslist [tcl::namespace::eval $parent [list ::tcl::namespace::children $tail]]
set nslist [nseval_ifexists $parent [list ::tcl::namespace::children $tail]]
return [lsort $nslist]
switch -- $opt_sort {
ascii {
return [lsort $nslist]
}
dictionary {
return [lsort -dictionary $nslist]
}
natural {
package require natsort
return [natsort::sort $nslist]
}
default {
return $nslist
}
}
}
#Note nsjoin,nsjoinall,nsprefix,nstail are string functions that don't care about namespaces in existence.
@ -1249,7 +1273,7 @@ tcl::namespace::eval punk::ns {
append path_text \n " cmds: $cmds"
}
} else {
#todo - change to display in column order to be same as main command listing
#todo - change to display in column order - so as to be same as main command listing
set parentcommands [dict get $nsdict commands]
dict for {k v} $nspathdict {
set rawpathcommands [dict get $v commands]
@ -1404,7 +1428,7 @@ tcl::namespace::eval punk::ns {
if {$allbelow == 0 && !$has_globchars} {
set allchildren [list]
} else {
set allchildren [nschildren $ch] ; #sorted, only returns 1 level deeper
set allchildren [nschildren -sort none $ch] ; #only returns 1 level deeper. leave sorting til after filtering
}
#nscommands returns exactly one line per entry + a trailing newline. If there is an empty line other than at the end - that is because there is a command named as the empty string.
@ -1784,10 +1808,17 @@ tcl::namespace::eval punk::ns {
}
}
}
#catch {package require natsort}
#if {[package provide natsort] ne ""} {
# set childtailmatches [natsort::sort $childtailmatches]
#} else {
# set childtailmatches [lsort $childtailmatches]
#}
set childtailmatches [lsort -dictionary $childtailmatches]
set nsdict [dict create\
location $location\
children [lsort $childtailmatches]\
children $childtailmatches\
commands $commands\
procs $procs\
exported $exported\

68
src/project_layouts/custom/_project/punk.project-0.1/src/bootsupport/modules/punk/path-0.1.0.tm

@ -686,6 +686,7 @@ namespace eval punk::path {
-directory -type directory -help\
"folder in which to begin recursive scan for files."
-call-depth-internal -default 0 -type integer
-sort -type any -default natural -choices {none ascii dictionary natural}
-antiglob_paths -default {} -help\
"list of path patterns to exclude
may include * and ** path segments e.g
@ -718,6 +719,7 @@ namespace eval punk::path {
lassign [dict values $argd] leaders opts values received
set tailglobs [dict get $values tailglobs]
# -- --- --- --- --- --- ---
set opt_sort [dict get $opts -sort]
set opt_antiglob_paths [dict get $opts -antiglob_paths]
set opt_antiglob_files [dict get $opts -antiglob_files]
set CALLDEPTH [dict get $opts -call-depth-internal]
@ -726,6 +728,9 @@ namespace eval punk::path {
set files [list]
if {$CALLDEPTH == 0} {
if {$opt_sort eq "natural"} {
package require natsort
}
#set opts [dict merge $opts [list -directory $opt_dir]]
if {![dict exists $received -directory]} {
set opt_dir [pwd]
@ -779,7 +784,20 @@ namespace eval punk::path {
} else {
set retained $matches
}
set dirfiles [lsort $retained]
switch -- $opt_sort {
ascii {
set dirfiles [lsort $retained]
}
dictionary {
set dirfiles [lsort -dictionary $retained]
}
natural {
set dirfiles [natsort::sort $retained]
}
default {
set dirfiles $retained
}
}
}
lappend files {*}$dirfiles
@ -787,7 +805,7 @@ namespace eval punk::path {
puts stderr "treefilenames error while listing subdirs in dir $opt_dir\n $dirdirs"
set dirdirs [list]
}
set okdirs [list]
foreach dir $dirdirs {
set skip 0
foreach anti $opt_antiglob_paths {
@ -796,11 +814,29 @@ namespace eval punk::path {
break
}
}
if {$skip} {
continue
if {!$skip} {
lappend okdirs $dir
}
}
if {[llength $okdirs]} {
switch -- $opt_sort {
ascii {
set finaldirs [lsort $okdirs]
}
dictionary {
set finaldirs [lsort -dictionary $okdirs]
}
natural {
set finaldirs [natsort::sort $okdirs]
}
default {
set finaldirs $okdirs
}
}
foreach dir $finaldirs {
set nextopts [dict merge $opts [list -directory $dir -call-depth-internal [incr CALLDEPTH]]]
lappend files {*}[treefilenames {*}$nextopts {*}$tailglobs]
}
set nextopts [dict merge $opts [list -directory $dir -call-depth-internal [incr CALLDEPTH]]]
lappend files {*}[treefilenames {*}$nextopts {*}$tailglobs]
}
return $files
}
@ -813,12 +849,16 @@ namespace eval punk::path {
# -- --- --- --- --- --- ---
set opt_antiglob_paths [dict get $opts -antiglob_paths]
set opt_antiglob_files [dict get $opts -antiglob_files]
set opt_sort [dict get $opts -sort]
set CALLDEPTH [dict get $opts -call-depth-internal]
# -- --- --- --- --- --- ---
# -- --- --- --- --- --- ---
set files [list]
if {$CALLDEPTH == 0} {
if {$opt_sort eq "natural"} {
package require natsort
}
#set opts [dict merge $opts [list -directory $opt_dir]]
if {![dict exists $received -directory]} {
set opt_dir [pwd]
@ -934,7 +974,21 @@ namespace eval punk::path {
}
}
}
return $filelist
switch -- $opt_sort {
ascii {
set finalfilelist [lsort $filelist]
}
dictionary {
set finalfilelist [lsort -dictionary $filelist]
}
natural {
set finalfilelist [natsort::sort $filelist]
}
default {
set finalfilelist $filelist
}
}
return $finalfilelist
}
#maint warning - also in punkcheck

19
src/project_layouts/custom/_project/punk.shell-0.1/src/bootsupport/modules/punk/args/tclcore-0.1.0.tm

@ -1648,6 +1648,25 @@ tcl::namespace::eval punk::args::tclcore {
}
# -- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
lappend PUNKARGS [list {
@id -id ::tcl::namespace::children
@cmd -name "Built-in: tcl::namespace::children"\
-summary\
"list child namespaces"\
-help\
"Returns a list of all child namespaces that belong to the namespace namespace.
If namespace is not specified, then the children are returned for the current
namespace. This command returns fully-qualified names, which start with a double
colon (::). If the optional pattern is given, then this command returns only the
names that match the glob-style pattern. The actual pattern used is determined as
follows: a pattern that starts with double colon (::) is used directly, otherwise
the namespace namespace (or the fully-qualified name of the current namespace) is
prepended onto the pattern."
@values
namespace -optional 1
pattern -optional 1
} "@doc -name Manpage: -url [manpage_tcl namespace]" ]
lappend PUNKARGS [list {
@id -id ::tcl::namespace::origin
@cmd -name "Built-in: tcl::namespace::origin" -help\

6
src/project_layouts/custom/_project/punk.shell-0.1/src/bootsupport/modules/punk/nav/fs-0.1.0.tm

@ -948,7 +948,7 @@ tcl::namespace::eval punk::nav::fs {
set flaggedhidden [punk::lib::lunique_unordered $flaggedhidden]
}
set dirs [lsort $dirs] ;#todo - natsort
set dirs [lsort -dictionary $dirs] ;#todo - natsort
@ -965,10 +965,10 @@ tcl::namespace::eval punk::nav::fs {
#Note - the sort by index would convert an empty filesizes list to a list of empty strings - one for each entry in files
#We want to preserve the empty list if that's what the dirlisting mechanism returned (presumably because -with_sizes was 0 or explicitly excluded files)
if {[llength $filesizes] == 0} {
set sorted_files [lsort $files]
set sorted_files [lsort -dictionary $files]
set sorted_filesizes [list]
} else {
set sortorder [lsort -indices $files]
set sortorder [lsort -indices -dictionary $files]
set sorted_files [list]
set sorted_filesizes [list]
foreach i $sortorder {

41
src/project_layouts/custom/_project/punk.shell-0.1/src/bootsupport/modules/punk/ns-0.1.0.tm

@ -311,7 +311,17 @@ tcl::namespace::eval punk::ns {
}
proc nschildren {ns} {
punk::args::define {
@id -id ::punk::ns::nschildren
@cmd -name punk::ns::nschildren
@opts
-sort -default "natural" -choices {none natural ascii dictionary}
ns
}
proc nschildren {args} {
set argd [punk::args::parse $args withid ::punk::ns::nschildren]
set opt_sort [dict get $argd opts -sort]
set ns [dict get $argd values ns]
set parts [nsparts $ns]
if {[lindex $parts 0] ne ""} {
#relative
@ -329,7 +339,21 @@ tcl::namespace::eval punk::ns {
#set nslist [nseval $parent [list ::namespace children $tail]]
#set nslist [tcl::namespace::eval $parent [list ::tcl::namespace::children $tail]]
set nslist [nseval_ifexists $parent [list ::tcl::namespace::children $tail]]
return [lsort $nslist]
switch -- $opt_sort {
ascii {
return [lsort $nslist]
}
dictionary {
return [lsort -dictionary $nslist]
}
natural {
package require natsort
return [natsort::sort $nslist]
}
default {
return $nslist
}
}
}
#Note nsjoin,nsjoinall,nsprefix,nstail are string functions that don't care about namespaces in existence.
@ -1249,7 +1273,7 @@ tcl::namespace::eval punk::ns {
append path_text \n " cmds: $cmds"
}
} else {
#todo - change to display in column order to be same as main command listing
#todo - change to display in column order - so as to be same as main command listing
set parentcommands [dict get $nsdict commands]
dict for {k v} $nspathdict {
set rawpathcommands [dict get $v commands]
@ -1404,7 +1428,7 @@ tcl::namespace::eval punk::ns {
if {$allbelow == 0 && !$has_globchars} {
set allchildren [list]
} else {
set allchildren [nschildren $ch] ; #sorted, only returns 1 level deeper
set allchildren [nschildren -sort none $ch] ; #only returns 1 level deeper. leave sorting til after filtering
}
#nscommands returns exactly one line per entry + a trailing newline. If there is an empty line other than at the end - that is because there is a command named as the empty string.
@ -1784,10 +1808,17 @@ tcl::namespace::eval punk::ns {
}
}
}
#catch {package require natsort}
#if {[package provide natsort] ne ""} {
# set childtailmatches [natsort::sort $childtailmatches]
#} else {
# set childtailmatches [lsort $childtailmatches]
#}
set childtailmatches [lsort -dictionary $childtailmatches]
set nsdict [dict create\
location $location\
children [lsort $childtailmatches]\
children $childtailmatches\
commands $commands\
procs $procs\
exported $exported\

68
src/project_layouts/custom/_project/punk.shell-0.1/src/bootsupport/modules/punk/path-0.1.0.tm

@ -686,6 +686,7 @@ namespace eval punk::path {
-directory -type directory -help\
"folder in which to begin recursive scan for files."
-call-depth-internal -default 0 -type integer
-sort -type any -default natural -choices {none ascii dictionary natural}
-antiglob_paths -default {} -help\
"list of path patterns to exclude
may include * and ** path segments e.g
@ -718,6 +719,7 @@ namespace eval punk::path {
lassign [dict values $argd] leaders opts values received
set tailglobs [dict get $values tailglobs]
# -- --- --- --- --- --- ---
set opt_sort [dict get $opts -sort]
set opt_antiglob_paths [dict get $opts -antiglob_paths]
set opt_antiglob_files [dict get $opts -antiglob_files]
set CALLDEPTH [dict get $opts -call-depth-internal]
@ -726,6 +728,9 @@ namespace eval punk::path {
set files [list]
if {$CALLDEPTH == 0} {
if {$opt_sort eq "natural"} {
package require natsort
}
#set opts [dict merge $opts [list -directory $opt_dir]]
if {![dict exists $received -directory]} {
set opt_dir [pwd]
@ -779,7 +784,20 @@ namespace eval punk::path {
} else {
set retained $matches
}
set dirfiles [lsort $retained]
switch -- $opt_sort {
ascii {
set dirfiles [lsort $retained]
}
dictionary {
set dirfiles [lsort -dictionary $retained]
}
natural {
set dirfiles [natsort::sort $retained]
}
default {
set dirfiles $retained
}
}
}
lappend files {*}$dirfiles
@ -787,7 +805,7 @@ namespace eval punk::path {
puts stderr "treefilenames error while listing subdirs in dir $opt_dir\n $dirdirs"
set dirdirs [list]
}
set okdirs [list]
foreach dir $dirdirs {
set skip 0
foreach anti $opt_antiglob_paths {
@ -796,11 +814,29 @@ namespace eval punk::path {
break
}
}
if {$skip} {
continue
if {!$skip} {
lappend okdirs $dir
}
}
if {[llength $okdirs]} {
switch -- $opt_sort {
ascii {
set finaldirs [lsort $okdirs]
}
dictionary {
set finaldirs [lsort -dictionary $okdirs]
}
natural {
set finaldirs [natsort::sort $okdirs]
}
default {
set finaldirs $okdirs
}
}
foreach dir $finaldirs {
set nextopts [dict merge $opts [list -directory $dir -call-depth-internal [incr CALLDEPTH]]]
lappend files {*}[treefilenames {*}$nextopts {*}$tailglobs]
}
set nextopts [dict merge $opts [list -directory $dir -call-depth-internal [incr CALLDEPTH]]]
lappend files {*}[treefilenames {*}$nextopts {*}$tailglobs]
}
return $files
}
@ -813,12 +849,16 @@ namespace eval punk::path {
# -- --- --- --- --- --- ---
set opt_antiglob_paths [dict get $opts -antiglob_paths]
set opt_antiglob_files [dict get $opts -antiglob_files]
set opt_sort [dict get $opts -sort]
set CALLDEPTH [dict get $opts -call-depth-internal]
# -- --- --- --- --- --- ---
# -- --- --- --- --- --- ---
set files [list]
if {$CALLDEPTH == 0} {
if {$opt_sort eq "natural"} {
package require natsort
}
#set opts [dict merge $opts [list -directory $opt_dir]]
if {![dict exists $received -directory]} {
set opt_dir [pwd]
@ -934,7 +974,21 @@ namespace eval punk::path {
}
}
}
return $filelist
switch -- $opt_sort {
ascii {
set finalfilelist [lsort $filelist]
}
dictionary {
set finalfilelist [lsort -dictionary $filelist]
}
natural {
set finalfilelist [natsort::sort $filelist]
}
default {
set finalfilelist $filelist
}
}
return $finalfilelist
}
#maint warning - also in punkcheck

19
src/vfs/_vfscommon.vfs/modules/punk/args/tclcore-0.1.0.tm

@ -1648,6 +1648,25 @@ tcl::namespace::eval punk::args::tclcore {
}
# -- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
lappend PUNKARGS [list {
@id -id ::tcl::namespace::children
@cmd -name "Built-in: tcl::namespace::children"\
-summary\
"list child namespaces"\
-help\
"Returns a list of all child namespaces that belong to the namespace namespace.
If namespace is not specified, then the children are returned for the current
namespace. This command returns fully-qualified names, which start with a double
colon (::). If the optional pattern is given, then this command returns only the
names that match the glob-style pattern. The actual pattern used is determined as
follows: a pattern that starts with double colon (::) is used directly, otherwise
the namespace namespace (or the fully-qualified name of the current namespace) is
prepended onto the pattern."
@values
namespace -optional 1
pattern -optional 1
} "@doc -name Manpage: -url [manpage_tcl namespace]" ]
lappend PUNKARGS [list {
@id -id ::tcl::namespace::origin
@cmd -name "Built-in: tcl::namespace::origin" -help\

6
src/vfs/_vfscommon.vfs/modules/punk/nav/fs-0.1.0.tm

@ -948,7 +948,7 @@ tcl::namespace::eval punk::nav::fs {
set flaggedhidden [punk::lib::lunique_unordered $flaggedhidden]
}
set dirs [lsort $dirs] ;#todo - natsort
set dirs [lsort -dictionary $dirs] ;#todo - natsort
@ -965,10 +965,10 @@ tcl::namespace::eval punk::nav::fs {
#Note - the sort by index would convert an empty filesizes list to a list of empty strings - one for each entry in files
#We want to preserve the empty list if that's what the dirlisting mechanism returned (presumably because -with_sizes was 0 or explicitly excluded files)
if {[llength $filesizes] == 0} {
set sorted_files [lsort $files]
set sorted_files [lsort -dictionary $files]
set sorted_filesizes [list]
} else {
set sortorder [lsort -indices $files]
set sortorder [lsort -indices -dictionary $files]
set sorted_files [list]
set sorted_filesizes [list]
foreach i $sortorder {

41
src/vfs/_vfscommon.vfs/modules/punk/ns-0.1.0.tm

@ -311,7 +311,17 @@ tcl::namespace::eval punk::ns {
}
proc nschildren {ns} {
punk::args::define {
@id -id ::punk::ns::nschildren
@cmd -name punk::ns::nschildren
@opts
-sort -default "natural" -choices {none natural ascii dictionary}
ns
}
proc nschildren {args} {
set argd [punk::args::parse $args withid ::punk::ns::nschildren]
set opt_sort [dict get $argd opts -sort]
set ns [dict get $argd values ns]
set parts [nsparts $ns]
if {[lindex $parts 0] ne ""} {
#relative
@ -329,7 +339,21 @@ tcl::namespace::eval punk::ns {
#set nslist [nseval $parent [list ::namespace children $tail]]
#set nslist [tcl::namespace::eval $parent [list ::tcl::namespace::children $tail]]
set nslist [nseval_ifexists $parent [list ::tcl::namespace::children $tail]]
return [lsort $nslist]
switch -- $opt_sort {
ascii {
return [lsort $nslist]
}
dictionary {
return [lsort -dictionary $nslist]
}
natural {
package require natsort
return [natsort::sort $nslist]
}
default {
return $nslist
}
}
}
#Note nsjoin,nsjoinall,nsprefix,nstail are string functions that don't care about namespaces in existence.
@ -1249,7 +1273,7 @@ tcl::namespace::eval punk::ns {
append path_text \n " cmds: $cmds"
}
} else {
#todo - change to display in column order to be same as main command listing
#todo - change to display in column order - so as to be same as main command listing
set parentcommands [dict get $nsdict commands]
dict for {k v} $nspathdict {
set rawpathcommands [dict get $v commands]
@ -1404,7 +1428,7 @@ tcl::namespace::eval punk::ns {
if {$allbelow == 0 && !$has_globchars} {
set allchildren [list]
} else {
set allchildren [nschildren $ch] ; #sorted, only returns 1 level deeper
set allchildren [nschildren -sort none $ch] ; #only returns 1 level deeper. leave sorting til after filtering
}
#nscommands returns exactly one line per entry + a trailing newline. If there is an empty line other than at the end - that is because there is a command named as the empty string.
@ -1784,10 +1808,17 @@ tcl::namespace::eval punk::ns {
}
}
}
#catch {package require natsort}
#if {[package provide natsort] ne ""} {
# set childtailmatches [natsort::sort $childtailmatches]
#} else {
# set childtailmatches [lsort $childtailmatches]
#}
set childtailmatches [lsort -dictionary $childtailmatches]
set nsdict [dict create\
location $location\
children [lsort $childtailmatches]\
children $childtailmatches\
commands $commands\
procs $procs\
exported $exported\

68
src/vfs/_vfscommon.vfs/modules/punk/path-0.1.0.tm

@ -686,6 +686,7 @@ namespace eval punk::path {
-directory -type directory -help\
"folder in which to begin recursive scan for files."
-call-depth-internal -default 0 -type integer
-sort -type any -default natural -choices {none ascii dictionary natural}
-antiglob_paths -default {} -help\
"list of path patterns to exclude
may include * and ** path segments e.g
@ -718,6 +719,7 @@ namespace eval punk::path {
lassign [dict values $argd] leaders opts values received
set tailglobs [dict get $values tailglobs]
# -- --- --- --- --- --- ---
set opt_sort [dict get $opts -sort]
set opt_antiglob_paths [dict get $opts -antiglob_paths]
set opt_antiglob_files [dict get $opts -antiglob_files]
set CALLDEPTH [dict get $opts -call-depth-internal]
@ -726,6 +728,9 @@ namespace eval punk::path {
set files [list]
if {$CALLDEPTH == 0} {
if {$opt_sort eq "natural"} {
package require natsort
}
#set opts [dict merge $opts [list -directory $opt_dir]]
if {![dict exists $received -directory]} {
set opt_dir [pwd]
@ -779,7 +784,20 @@ namespace eval punk::path {
} else {
set retained $matches
}
set dirfiles [lsort $retained]
switch -- $opt_sort {
ascii {
set dirfiles [lsort $retained]
}
dictionary {
set dirfiles [lsort -dictionary $retained]
}
natural {
set dirfiles [natsort::sort $retained]
}
default {
set dirfiles $retained
}
}
}
lappend files {*}$dirfiles
@ -787,7 +805,7 @@ namespace eval punk::path {
puts stderr "treefilenames error while listing subdirs in dir $opt_dir\n $dirdirs"
set dirdirs [list]
}
set okdirs [list]
foreach dir $dirdirs {
set skip 0
foreach anti $opt_antiglob_paths {
@ -796,11 +814,29 @@ namespace eval punk::path {
break
}
}
if {$skip} {
continue
if {!$skip} {
lappend okdirs $dir
}
}
if {[llength $okdirs]} {
switch -- $opt_sort {
ascii {
set finaldirs [lsort $okdirs]
}
dictionary {
set finaldirs [lsort -dictionary $okdirs]
}
natural {
set finaldirs [natsort::sort $okdirs]
}
default {
set finaldirs $okdirs
}
}
foreach dir $finaldirs {
set nextopts [dict merge $opts [list -directory $dir -call-depth-internal [incr CALLDEPTH]]]
lappend files {*}[treefilenames {*}$nextopts {*}$tailglobs]
}
set nextopts [dict merge $opts [list -directory $dir -call-depth-internal [incr CALLDEPTH]]]
lappend files {*}[treefilenames {*}$nextopts {*}$tailglobs]
}
return $files
}
@ -813,12 +849,16 @@ namespace eval punk::path {
# -- --- --- --- --- --- ---
set opt_antiglob_paths [dict get $opts -antiglob_paths]
set opt_antiglob_files [dict get $opts -antiglob_files]
set opt_sort [dict get $opts -sort]
set CALLDEPTH [dict get $opts -call-depth-internal]
# -- --- --- --- --- --- ---
# -- --- --- --- --- --- ---
set files [list]
if {$CALLDEPTH == 0} {
if {$opt_sort eq "natural"} {
package require natsort
}
#set opts [dict merge $opts [list -directory $opt_dir]]
if {![dict exists $received -directory]} {
set opt_dir [pwd]
@ -934,7 +974,21 @@ namespace eval punk::path {
}
}
}
return $filelist
switch -- $opt_sort {
ascii {
set finalfilelist [lsort $filelist]
}
dictionary {
set finalfilelist [lsort -dictionary $filelist]
}
natural {
set finalfilelist [natsort::sort $filelist]
}
default {
set finalfilelist $filelist
}
}
return $finalfilelist
}
#maint warning - also in punkcheck

Loading…
Cancel
Save