GitXplorerGitXplorer
f

commander-to-fig

public
0 stars
0 forks
0 issues

Commits

List of commits on branch main.
Unverified
aaa67b4f76a58b73b45169dd381ea1ee289e7516

test: fix alias fixture

ffedeci committed 3 years ago
Unverified
d82fd5044b855341596b810dc369dd8bede044a2

test: update fixtures

ffedeci committed 3 years ago
Unverified
a7e00c1a84a1991fd9dc0534f472edf87d2e9c7d

feat: add command description

ffedeci committed 3 years ago
Unverified
a199f6354f5fcba23c91956aa901529cec0a1bb6

feat: add help commands/options

ffedeci committed 3 years ago
Unverified
d88d86beaeb297eadf580e27b32f375dc72ba8a2

test: pass `__dirname` as cwd

ffedeci committed 3 years ago
Unverified
ffbc41ac4b7de9ece9d95034963edee0ffb2338c

fix CI

ffedeci committed 3 years ago

README

The README file for this repository.

⚠️ 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.