DocsGeneratorCustom

Custom Generators

Write imperative code where suggestions must be recomputed on every keypress.

With a Custom Generator, you define a function that takes the tokenized array of the user's input, execute multiple shell commands on the user's machine, and then generate suggestions to display. Essentially, this combines the script and postProcess workflow in a single function.

When writing a Custom Generator, make sure to familiarize yourself with the "Trigger" API.

While Fig's completion spec standard supports the vast majority of CLI tools declaratively, some tools offer features that won't work with the standard spec. Custom Generators enable you to write more complex logic and generate suggestions that take these edge cases into account.

subargs

One example of where the completion spec standard breaks is when an argument takes its own sub-arguments that are not delimited by a space.

On this page