DocsIntegratingIntegrationsCommander

Fig Autocomplete & Commander.js

This tutorial will walk you through setting up Fig's integration with JS CLI framework, Commander.

Configure the @fig/complete-commander commander extension

# Go to your CLI's project
cd path/to/my/project

# Install the dependency
npm i -D @fig/complete-commander
# or if you are using yarn
yarn add -D @fig/complete-commander
// index.js
import { addCompletionSpecCommand } from '@fig/complete-commander'
import { program } from 'commander'

// Configure your program here...
program
  .command('some-cmd')
  .description('The description of the command')

addCompletionSpecCommand(program) // This adds the "generate-fig-spec" subcommand to main program

program.parse()

Now running node index.js generate-fig-spec will print the spec.

See other ways of using @fig/complete-commander extension in the package README

Next Steps: now that you have successfully configured the integration you can either push the spec to the autocomplete repo or push it to Fig's cloud.