-
Notifications
You must be signed in to change notification settings - Fork 6
/
cli.py
41 lines (37 loc) · 947 Bytes
/
cli.py
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
import click
from .utils import parse_metadata, run_indexer
@click.group()
@click.version_option()
def cli():
"Dogsheep search index"
@cli.command()
@click.argument(
"db_path",
type=click.Path(file_okay=True, dir_okay=False, allow_dash=False),
required=True,
)
@click.argument(
"config",
type=click.Path(file_okay=True, dir_okay=False, allow_dash=True),
required=True,
)
@click.option(
"--tokenize",
help="Tokenizer to use. Defaults to porter, set to none to disable.",
default="porter",
)
@click.option(
"-d",
"--database",
multiple=True,
help="Databases to index - defaults to all",
)
def index(db_path, config, tokenize, database):
"Create a search index based on rules in the config file"
rules = parse_metadata(open(config).read())
run_indexer(
db_path,
rules,
tokenize=None if tokenize == "none" else tokenize,
databases=database,
)