I have a TreeCompleter
(Scala code) which works as expected:
val treeCompleter = new TreeCompleter(
node("bindkey"),
node("cls"),
node(
"custom",
node("Option1", node("Param1", "Param2")),
node("Option2"),
node("Option3")
),
node("help"),
node("set"),
node("testkey"),
node("tput")
)
How can I obtain the collection of command names? For this example, those names are: bindkey
, cls
, custom
, help
, set
, testkey
and tput
.
The github project that contains the above code is here: https://github.com/mslinn/jline-example/blob/master/src/main/scala/CliLoop.scala
I don't care if the answer is in Java or Scala, thanks!
I don't think it is possible this way given that
TreeCompleter
is just a wrapper aroundRegexCompleter
that actually does the job. So if you want to gather this information, you should do it before you pass your nodes to theTreeCompleter
constructor or probably before you createTreeCompleter.Node
instances because they seem to provide no public accessors. One obvious solution would be to create your own wrapper aroundTreeCompleter
with your own innerNode
class that would store this information for later usage.