Skip to content

Expansion Completers

maxlandon edited this page Apr 30, 2021 · 5 revisions

Expansion Completions

Another feature of this library is the ability you have to bind expanded variable completions. The way it works has 2 advantages, highlighted by the current example (a default env variable completer):

// When we are in the server menu, we want access to our ENV variables
serverMenu.AddExpansionCompletion('$', console.Completer.EnvironmentVariables)

These completers accept a single rune prefix, which when detected anywhere in the shell (even in the middle of a path), will give you these completion groups to use.

complete-env-gif

Notes:

  • You NEED to pass a function returning a TabDisplayList group, which its descriptions map populated for every var. Go to the section below to understand why.
  • As you can see, these variable completion groups are specific to a given menu.

Expansion Parsing & Evaluation

In addition to providing completion for these expanded variables, the shell will automatically parse any of them when the user enters a command line input that contains these. For doing that, the shell calls the completer again at execution time, and replaces all keys found in the line:

evaluate-env-gif