Skip to content

Commit

Permalink
Add 'setup db --download' CLI option
Browse files Browse the repository at this point in the history
  • Loading branch information
JWCook committed Jul 2, 2024
1 parent 51321e8 commit 7a8bfa1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
6 changes: 6 additions & 0 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@ initialize it for the first time, reset it, or download missing data for taxon t

Options:
```bash
-d, --download Download taxonomy data if it does not exist locally
-f, --force Reset database if it already exists
```
Example: Full reset and download, with debug logs:
```bash
nt -vv setup db -f -d
```
### Shell
The `setup shell` command sets up optional shell tab-completion.
Expand Down
16 changes: 14 additions & 2 deletions naturtag/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,20 +216,32 @@ def setup_group():


@setup_group.command()
@click.option(
'-d',
'--download',
is_flag=True,
help='Download taxonomy data if it does not exist locally',
)
@click.option(
'-f',
'--force',
is_flag=True,
help='Reset database if it already exists',
)
def db(force):
def db(download, force):
"""Set up Naturtag's local database.
Naturtag uses a SQLite database to store observation and taxonomy data. This command can
initialize it for the first time, reset it, or download missing data for taxon text search.
\b
Example: Full reset and download, with debug logs:
```
nt -vv setup db -f -d
```
"""
click.echo('Initializing database...')
setup(overwrite=force)
setup(overwrite=force, download=download)


@setup_group.command()
Expand Down

0 comments on commit 7a8bfa1

Please sign in to comment.