# cli


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

There are no hand-written command wrappers here.
[`cmd`](https://vedicreader.github.io/vishalakshi/cli.html#cmd) turns
any [`Vault`](https://vedicreader.github.io/vishalakshi/core.html#vault)
method into a plain function — `self` and `**kw` stripped — and
fastcore’s `anno_parser` reads the docments off it, so every flag,
default and help string in the CLI *is* the source of the method it
calls. Adding a method to `CMDS` is the whole of adding a command.

------------------------------------------------------------------------

<a
href="https://github.com/vedicreader/vishalakshi/blob/main/vishalakshi/cli.py#L30"
target="_blank" style="float:right; font-size:smaller">source</a>

### cmd

``` python
def cmd(
    name:str, vault_fn:_lru_cache_wrapper=vault
):
```

*A [`Vault`](https://vedicreader.github.io/vishalakshi/core.html#vault)
method as a plain function: `self` and `**kw` dropped, docments kept.*

`__delwrap__` is what makes the second half work — `docments` walks it
to find the comments in the original source, so `anno_parser` and MCP
both get help text for free.

------------------------------------------------------------------------

<a
href="https://github.com/vedicreader/vishalakshi/blob/main/vishalakshi/cli.py#L25"
target="_blank" style="float:right; font-size:smaller">source</a>

### vault

``` python
def vault(
    path:str=None
)->Vault:
```

*The vault every command shares: `$VISHALAKSHI_VAULT`, else the default
path.*

------------------------------------------------------------------------

<a
href="https://github.com/vedicreader/vishalakshi/blob/main/vishalakshi/cli.py#L57"
target="_blank" style="float:right; font-size:smaller">source</a>

### main

``` python
def main():
```

*Entry point for the `vishalakshi` command. `vishalakshi <cmd> --help`
documents any command.*

------------------------------------------------------------------------

<a
href="https://github.com/vedicreader/vishalakshi/blob/main/vishalakshi/cli.py#L49"
target="_blank" style="float:right; font-size:smaller">source</a>

### show

``` python
def show(
    r
):
```

*Print a result: an answer as prose with its citations, anything else as
JSON.*

------------------------------------------------------------------------

<a
href="https://github.com/vedicreader/vishalakshi/blob/main/vishalakshi/cli.py#L44"
target="_blank" style="float:right; font-size:smaller">source</a>

### jsonable

``` python
def jsonable(
    o
):
```

*`json.dumps` fallback: `L` and friends become lists, numpy scalars
numbers, the rest strings.*

## Try it

``` python
p = anno_parser(cmd('find'), prog='vishalakshi find')
p.print_help()
```

``` python
args = p.parse_args(['late chunking', '--limit', '3', '--kind', 'note,web']).__dict__
test_eq(args['q'], 'late chunking'); test_eq(args['limit'], 3); test_eq(args['kind'], 'note,web')
test_eq(sorted(set(CMDS) - {m for m in dir(Vault) if not m.startswith('_')}), [])   # every command is a real method
test_eq(json.loads(json.dumps(L(['a', 'b']), default=jsonable)), ['a', 'b'])        # `L` is not a list; JSON needs telling
```
