Handbook
Glossary
paths-matching ( str -- seq )
Vocabulary
tools
.
completion
Inputs
str
a
string
Outputs
seq
an
assoc
Word description
Returns fuzzy pathname completions. Relative input is resolved against the current directory, including filename prefixes without a directory separator. An optional leading P" is preserved in completion strings.
Definition
USING:
assocs
combinators.short-circuit
io.files
io.files.info
io.pathnames
kernel
math
sequences
splitting
tools.completion.private
;
IN:
tools.completion
:
paths-matching
( str -- seq )
"P\""
?head
[
dup
last-path-separator
[
1
+
cut
]
[
drop
""
swap
]
if
swap
dup
{
[
file-exists?
]
[
file-info
directory?
]
}
1&&
[
directory-paths
completions
]
[
2drop
{
}
]
if
]
dip
[
[
[
"P\""
prepend
]
dip
]
assoc-map
]
when
;