File: README.md

package info (click to toggle)
golang-github-withfig-autocomplete-tools 0.0~git20241029.747689a%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,456 kB
  • sloc: javascript: 2,543; python: 734; sh: 20; makefile: 13
file content (36 lines) | stat: -rw-r--r-- 916 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
## Autogenerate Completions for CLI tools built with `argparse`

This package generates [Fig
completions](https://github.com/withfig/autocomplete) for CLI tools built
with Python's built-in [argparse](https://docs.python.org/3/library/argparse.html) module.

### Installation

Install the integration as a dependency using pip:

```bash
pip install argparse-complete-fig
```

### Usage

```python
import argparse
from argparse_complete_fig import add_completion_spec_command

parser = argparse.ArgumentParser(prog='my-cli')

# Call on your root-level parser for full completions
add_completion_spec_command(parser)
```

Calling the `add_completion_spec_command` function will add
a `--generate-fig-spec` argument to the parser. When your CLI is invoked
with this flag it will print a Fig spec.


To save your completion spec skeleton to a file, run the following:

```bash
my-cli --generate-fig-spec > my-cli.ts
```