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 (94 lines) | stat: -rw-r--r-- 2,123 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
## Autogenerate Completions for CLI tools built with `cement`

This package generates [Fig
completions](https://github.com/withfig/autocomplete) for CLI tools built
on [Cement](https://builtoncement.com/).


### Installation

Install the integration as a dependency using pip:

```bash
pip install cement-complete-fig
```

### Usage

Choose one of the methods below to add the `generate-fig-spec`
subcommand to the top level of your CLI tool.

#### Method 1: Load as a Cement extension

This package provides a [Cement
extension](https://docs.builtoncement.com/core-foundation/extensions-1)
for convenience called `'cement_complete_fig.ext.ext_complete_fig'`
which can be loaded in any of the ways cited in the linked documentation.

Repeated here for convenience you can do one of the following:

1. Add the extension to the `Meta` of your `App` object:

```python
from cement import App

class MyApp(App):
    class Meta:
        label = 'myapp'
        extensions = [
            ...,
            'cement_complete_fig.ext.ext_complete_fig'
       ]
```


2. Manually load the extension before running your app:

```python
from cement import App

with App('myapp') as app:
    app.ext.load_extension('cement_complete_fig.ext.ext_complete_fig')

    app.run()
```

3. Add the extension to your app configuration file (e.g. `.myapp.conf`):

```toml
[myapp]
exensions = cement_complete_fig.ext.ext_complete_fig
```

#### Method 2: Bind the controller manually

You can also add the `GenerateFigSpecController` manually as a handler to your
app:

```python
from cement import App
from cement_complete_fig import GenerateFigSpecController

class MyApp(App):
    class Meta:
        label = 'myapp'
        handlers = [
            ...,
            GenerateFigSpecController
        ]

with MyApp() as app:
    app.run()
```

### Generating the spec file

Once you've added the integration you will have new subcommand nested
under your base handler.  When this subcommand is invoked it will print
a Fig spec.

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

```bash
myapp generate-fig-spec > myapp.ts
```