Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ All AFQuery commands follow the pattern `afquery <command> [OPTIONS]`.

---

## Global options

| Option | Description |
|--------|-------------|
| `--version` | Print the AFQuery version and exit |
| `--help` | Show help for the command and exit |

`afquery --version` prints the installed package version (e.g. `afquery 0.4.2`),
taken from the Git release tag at build time. In an editable install
(`pip install -e .`) it reflects the last build, not later local commits.

---

## create-db

Build a new AFQuery database from a manifest of single-sample VCFs.
Expand Down
19 changes: 12 additions & 7 deletions src/afquery/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import click

from afquery import __version__

from .database import Database


Expand Down Expand Up @@ -168,15 +170,18 @@ def _print_carriers(carriers, variant_key, fmt: str) -> None:
click.echo(fmt_row.format(*row))


@click.group()
def cli():
"""AFQuery: bitmap-indexed allele frequency engine for local genomic cohorts.
_CLI_HELP = f"""\
AFQuery v{__version__} — bitmap-indexed allele frequency engine for local genomic cohorts.

Enables fast AC/AN/AF queries on user-defined subcohorts (phenotype, sex,
technology) without rescanning VCFs.
Enables fast AC/AN/AF queries on user-defined subcohorts (phenotype, sex,
technology) without rescanning VCFs.
"""

Commands: query, variant-info, annotate, dump, info, version, create-db, update-db, check, benchmark
"""

@click.group(help=_CLI_HELP)
@click.version_option(version=__version__, prog_name="afquery", message="%(prog)s %(version)s")
def cli():
pass


@cli.command()
Expand Down
23 changes: 23 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,29 @@ def test_version_set_then_show(runner, db_copy):
assert "MYVER" in result.output


# --- afquery --version / --help ---

def test_version_flag(runner):
from afquery import __version__
result = runner.invoke(cli, ["--version"])
assert result.exit_code == 0
assert __version__ in result.output


def test_help_shows_program_name_and_version(runner):
from afquery import __version__
result = runner.invoke(cli, ["--help"])
assert result.exit_code == 0
assert f"AFQuery v{__version__}" in result.output


def test_help_lists_all_commands(runner):
result = runner.invoke(cli, ["--help"])
for cmd in ("query", "variant-info", "annotate", "dump", "info",
"version", "create-db", "update-db", "check", "benchmark"):
assert cmd in result.output


# --- afquery check ---

def test_check_ok(runner, test_db):
Expand Down
Loading