Skip to content

Commit

Permalink
FIX: include user context values in the help output
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Nov 18, 2021
1 parent cfe7e2a commit e26d3d4
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions src/mezz/mezz-help.reb
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ import module [
/weak "Provides sorting and does not displays unset values"
/match "Include only those that match a string or datatype"
pattern
/only {Do not display "no info" message}
/local start wild type str result
/local start wild type str result user?
][
result: clear ""
user?: same? obj system/contexts/user
; Search for matching strings:
wild: all [string? pattern find pattern "*"]
foreach [word val] obj [
Expand All @@ -150,6 +150,9 @@ import module [
type = :pattern
]
][
; don't show user context values if these are same like library ones
if all [user? any [ word = 'lib-local same? val select system/contexts/lib word]][ continue ]

str: join "^[[1;32m" form-pad word 15
append str "^[[m "
append str form-pad type 11 - min 0 ((length? str) - 15)
Expand All @@ -161,9 +164,7 @@ import module [
]
]
]
either all [pattern empty? result not only] [
ajoin ["No information on: ^[[32m" pattern "^[[m^/"]
][ copy result ]
copy result
]

out-description: func [des [block!]][
Expand All @@ -179,12 +180,11 @@ import module [
'word [any-type!]
/into "Help text will be inserted into provided string instead of printed"
string [string!] "Returned series will be past the insertion"
/local value spec args refs rets type ret desc arg def des ref str cols
/local value spec args refs rets type ret desc arg def des ref str cols tmp
][
;@@ quering buffer width in CI under Windows now throws error: `Access error: protocol error: 6`
;@@ it should return `none` like under Posix systems!
cols: try [ query/mode system/ports/input 'buffer-cols ]
unless integer? cols [ cols: 120 ]
cols: any [ attempt [ query/mode system/ports/input 'buffer-cols ] 120]
max-desc-width: cols - 35
buffer: any [string clear ""]
catch [
Expand All @@ -209,7 +209,20 @@ import module [
][ word: mold :word ] ;or use it as a string input
]
string? :word [
output dump-obj/weak/match system/contexts/lib :word
tmp: false
case/all [
not empty? value: dump-obj/weak/match system/contexts/lib :word [
output ajoin ["Found these related matches:^/" value]
tmp: true
]
not empty? value: dump-obj/weak/match system/contexts/user :word [
output ajoin ["Found these related matches in the user context:^/" value]
tmp: true
]
not tmp [
output ajoin ["No information on: ^[[32m" :word "^[[m^/"]
]
]
throw true
]
datatype? :value [
Expand All @@ -226,9 +239,12 @@ import module [
"It is defined as" either find "aeiou" first spec/title [" an "] [" a "] spec/title ".^/"
"It is of the general type ^[[1;32m" spec/type "^[[m.^/^/"
]
unless empty? value: dump-obj/match/only system/contexts/lib :word [
unless empty? value: dump-obj/match system/contexts/lib :word [
output ajoin ["Found these related words:^/" value]
]
unless empty? value: dump-obj/match system/contexts/user :word [
output ajoin ["Found these related words in the user context:^/" value]
]
]
throw true
]
Expand Down

0 comments on commit e26d3d4

Please sign in to comment.