Skip to content
Merged
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
39 changes: 24 additions & 15 deletions chaintools_bio/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,10 @@
stats,
)

app = typer.Typer(help="Utilities for the genomic chain format")


def version_callback(value: bool):
if value:
print(f"chaintools_bio version: {__version__}")
raise typer.Exit()
app = typer.Typer(
help="Utilities for the genomic chain format",
no_args_is_help=True,
)


class CoordSystem(str, Enum):
Expand Down Expand Up @@ -87,10 +84,10 @@ def to_sam_cmd(
"", "-o", "--output", help="Path to the output SAM file"
),
target_fasta: str = typer.Option(
"", "-t", "--target-fasta", help="Path to the target FASTA file"
..., "-t", "--target-fasta", help="Path to the target FASTA file"
),
query_fasta: str = typer.Option(
"", "-q", "--query-fasta", help="Path to the query FASTA file"
..., "-q", "--query-fasta", help="Path to the query FASTA file"
),
):
"""Convert a chain file to the SAM format"""
Expand All @@ -111,10 +108,10 @@ def to_vcf_cmd(
"", "-o", "--output", help="Path to the output VCF file"
),
target_fasta: str = typer.Option(
"", "-t", "--target-fasta", help="Path to the target FASTA file"
..., "-t", "--target-fasta", help="Path to the target FASTA file"
),
query_fasta: str = typer.Option(
"", "-q", "--query-fasta", help="Path to the query FASTA file"
..., "-q", "--query-fasta", help="Path to the query FASTA file"
),
):
"""Convert a chain file to the VCF format"""
Expand Down Expand Up @@ -163,7 +160,7 @@ def annotate_cmd(
"", "-o", "--output", help="Path to the output annotated chain file"
),
bed_prefix: str = typer.Option(
..., "-b", "--bed-prefix", help="Prefix for BED output files"
"", "-b", "--bed-prefix", help="Prefix for BED output files"
),
summary: str = typer.Option(
"", "-s", "--summary", help="Path to summary output file"
Expand Down Expand Up @@ -237,12 +234,24 @@ def stats_cmd(
stats.stats(fn_chain=chain, fn_out=output)


@app.callback()
def main(
def _version_callback(value: bool):
if value:
print(f"chaintools_bio version: {__version__}")
raise typer.Exit()


@app.callback(invoke_without_command=True)
def version_callback(
version: bool = typer.Option(
None, "--version", callback=version_callback, is_eager=True
None, "--version", callback=_version_callback, is_eager=True
),
):
pass


def main():
"""Primary entry point for the CLI."""
version_callback()
app()


Expand Down