Browse Source

punk::args fix, dev lib.search fixes and docs

master
Julian Noble 5 months ago
parent
commit
941735ce6f
  1. 21
      src/modules/picalc-999999.0a1.0.tm
  2. 21
      src/modules/punk/args-999999.0a1.0.tm
  3. 56
      src/modules/punk/mix/commandset/loadedlib-999999.0a1.0.tm
  4. 37
      src/modules/punk/path-999999.0a1.0.tm

21
src/modules/picalc-999999.0a1.0.tm

@ -46,7 +46,7 @@
#[list_begin itemized]
package require Tcl 8.6-
package require punk::lib
package require punk::lib
package require punk::args
#*** !doctools
#[item] [package {Tcl 8.6}]
@ -73,10 +73,18 @@ tcl::namespace::eval picalc {
# ++ +++ +++ +++ +++ +++ +++ +++ +++ +++ +++
#*** !doctools
#[subsection {Namespace picalc}]
#[para] Core API functions for picalc
#[para] Core API functions for picalc
#[list_begin definitions]
variable PUNKARGS
variable PUNKARGS_aliases
lappend PUNKARGS [list {
@id -id "(package)picalc"
@package -name "picalc"\
-help\
"A test/learning experimental package for pi calculation"
}]
@ -475,15 +483,6 @@ tcl::namespace::eval picalc::lib {
# == === === === === === === === === === === === === === ===
tcl::namespace::eval picalc {
tcl::namespace::export {[a-z]*} ;# Convention: export all lowercase
variable PUNKARGS
variable PUNKARGS_aliases
lappend PUNKARGS [list {
@id -id "(package)picalc"
@package -name "picalc" -help\
"Package
Description"
}]
namespace eval argdoc {
#namespace for custom argument documentation

21
src/modules/punk/args-999999.0a1.0.tm

@ -2606,11 +2606,11 @@ tcl::namespace::eval punk::args {
@values {set defaults_key VALSPEC_DEFAULTS}
}
if {[dict exists $opt_override $type]} {
append result \n "$type [dict merge [dict get $specdict FORMS $formname LEADERSPEC_DEFAULTS] [dict get $opt_override $type]]"
dict set resultdict $type [dict merge [dict get $specdict FORMS $formname LEADERSPEC_DEFAULTS] [dict get $opt_override $type]]
append result \n "$type [dict merge [dict get $specdict FORMS $formname $defaults_key] [dict get $opt_override $type]]"
dict set resultdict $type [dict merge [dict get $specdict FORMS $formname $defaults_key] [dict get $opt_override $type]]
} else {
append result \n "$type [dict get $specdict FORMS $formname LEADERSPEC_DEFAULTS]"
dict set resultdict $type [dict get $specdict FORMS $formname LEADERSPEC_DEFAULTS]
append result \n "$type [dict get $specdict FORMS $formname $defaults_key]"
dict set resultdict $type [dict get $specdict FORMS $formname $defaults_key]
}
}
}
@ -2856,6 +2856,19 @@ tcl::namespace::eval punk::args {
return $result
}
lappend PUNKARGS [list {
@id -id ::punk::args::update_definitions
@cmd -name punk::args::update_definitions\
-summary\
""\
-help\
""
@values -min 1
id
arglist -type list -help\
"list containing arguments to be parsed as per the
argument specification identified by the supplied id."
}]
#scanned_packages (list)
#namespace_docpackages (dict)
proc update_definitions {{nslist *}} {

56
src/modules/punk/mix/commandset/loadedlib-999999.0a1.0.tm

@ -35,23 +35,39 @@ namespace eval punk::mix::commandset::loadedlib {
-highlight -type boolean -default 1 -help\
"Highlight which version is present with ansi underline and colour"
-refresh -default 0 -type boolean -help "Re-scan the tm and library folders"
searchstrings -default * -multiple 1 -help\
searchstring -default * -multiple 1 -help\
"Names to search for, may contain glob chars (* ?) e.g *lib*
If no glob chars are explicitly specified, the searchstring will be wrapped with star globs.
eg name -> *name*
To search for an exact name prefix it with =
e.g =name -> name
"
If no glob chars are explicitly specified, the searchstring will be wrapped with star globs.
eg name -> *name*
To search for an exact name prefix it with =
e.g =name -> name
If search is not prefixed with '=' the search is case insensitive."
}
proc search {args} {
set argd [punk::args::get_by_id ::punk::mix::commandset::loadedlib::search $args]
set searchstrings [dict get $argd values searchstrings]
set searchstrings [dict get $argd values searchstring]
set opts [dict get $argd opts]
set opt_return [dict get $opts -return]
set opt_highlight [dict get $opts -highlight]
set opt_refresh [dict get $opts -refresh]
if {$opt_refresh} {
catch {package require frobznodule666} ;#ensure pkg system has loaded/searched for everything REVIEW - this doesn't result in full scans
foreach tm_path [tcl::tm::list] {
set paths_below [punk::path::subfolders -recursive $tm_path]
foreach folder $paths_below {
set tail [file tail $folder]
if {[string match #modpod-* $tail] || [string match #tarjar-* $tail]} {
continue
}
if {[string match */_build/* $folder]} {continue}
set relpath [string tolower [punk::path::relative $tm_path $folder]]
set modpath [string map {/ ::} $relpath]
catch {package require ${modpath}::flobrudder99}
}
}
}
#REVIEW - this doesn't result in full scans
catch {package require frobznodule666} ;#ensure pkg system has loaded/searched for everything
set packages [package names]
set matches [list]
@ -122,9 +138,25 @@ namespace eval punk::mix::commandset::loadedlib {
}
}
}
proc loaded.search {searchstring} {
set search_result [search $searchstring]
set all_libs [split $search_result \n]
punk::args::define {
@id -id ::punk::mix::commandset::loadedlib::loaded.search
@cmd -name "punk::mix::commandset::loadedlib loaded.search"\
-summary\
"Search loaded libraries."\
-help "search all Tcl libraries currently loaded in your local interpreter.
ie those that have been loaded directly or indirectly by 'package require'."
}\
@values\
[punk::args::resolved_def -types values ::punk::mix::commandset::loadedlib::search searchstring]
proc loaded.search {args} {
set argd [punk::args::parse $args withid ::punk::mix::commandset::loadedlib::loaded.search]
lassign [dict values $argd] leaders opts values
set searchstrings [dict get $values searchstring]
set all_libs [search -return list -highlight 0 {*}$searchstrings]
set col1items [list]
set col2items [list]
set col3items [list]

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

@ -99,7 +99,7 @@ package require punk::args
# Base namespace
# ++ +++ +++ +++ +++ +++ +++ +++ +++ +++ +++
namespace eval punk::path {
namespace export *
namespace export {[a-z]*}
#variable xyz
#*** !doctools
@ -645,6 +645,41 @@ namespace eval punk::path {
}
return $ismatch
}
punk::args::define {
@id -id ::punk::path::subfolders
@cmd -name punk::path::subfolders\
-summary\
"Listing of directories within supplied path."\
-help\
"List of folders below path.
The resulting list is unsorted."
@opts
-recursive -type none -help\
""
#todo -depth
@values -min 0 -max 1
path -type directory -optional 1 -help\
"Path of folder. If not supplied current directory is used."
}
proc subfolders {args} {
set argd [punk::args::parse $args withid ::punk::path::subfolders]
lassign [dict values $argd] leaders opts values received
set do_recursion [dict exists $received -recursive]
if {[dict exists $received path]} {
set path [dict get $values path]
} else {
set path [pwd]
}
set folders [glob -nocomplain -directory $path -types d *]
if {$do_recursion} {
foreach subdir $folders {
lappend folders {*}[subfolders -recursive $subdir]
}
}
return $folders
}
#todo - treefolders with similar search caps as treefilenames
punk::args::define {
@id -id ::punk::path::treefilenames

Loading…
Cancel
Save