Debian Codegraph @

integrations/argparse/README.md

raw symbols SCIP
1 ## Autogenerate Completions for CLI tools built with `argparse`
2
3 This package generates [Fig
4 completions](https://github.com/withfig/autocomplete) for CLI tools built
5 with Python's built-in [argparse](https://docs.python.org/3/library/argparse.html) module.
6
7 ### Installation
8
9 Install the integration as a dependency using pip:
10
11 ```bash
12 pip install argparse-complete-fig
13 ```
14
15 ### Usage
16
17 ```python
18 import argparse
19 from argparse_complete_fig import add_completion_spec_command
20
21 parser = argparse.ArgumentParser(prog='my-cli')
22
23 # Call on your root-level parser for full completions
24 add_completion_spec_command(parser)
25 ```
26
27 Calling the `add_completion_spec_command` function will add
28 a `--generate-fig-spec` argument to the parser. When your CLI is invoked
29 with this flag it will print a Fig spec.
30
31
32 To save your completion spec skeleton to a file, run the following:
33
34 ```bash
35 my-cli --generate-fig-spec > my-cli.ts
36 ```