Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

fedeci/commander-to-fig

Repository files navigation

⚠️ NOTE: this integration is now @withfig/commander and has moved into the the autocomplete-tools monorepo.

Commander-to-fig

CI

A tool to speed up the workflow of converting Commander commands to Fig completion spec files.


Docs

generateFigSpec(command, filename[, options]): void
  • command: a commander.Command object
  • filename: the output filename of the completion spec file
  • options: an object containing the following optional properties:
    • cwd: specify the working directory in which the file will be saved. It defaults to process.cwd()

Usage

Using this library is as simple as importing a function and calling it.

import { program } from 'commander'
import { generateFigSpec } from '@withfig/commander'

program
  .name('babel')
  .description('The compiler for writing next generation JavaScript')
  .version('1.0.0')
  .argument('<file>', 'file to compile')

generateFigSpec(program, 'babel-spec.ts')

Specify the working directory

For example you may want to generate the file in an home directory subfolder for testing purpose.

import path from 'path'
import os from 'os'

...

// this will output to ~/generated/babel-spec.ts
generateFigSpec(program, 'babel-spec.ts', { cwd: path.join(os.homedir(), 'generated') })

p.s. this tool has been written for commander@8, but should work in the most of the previous versions too.

About

A tool to export Commander commands as Fig spec files

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published