Skip to content

Commit

Permalink
implement --registered and --stats options
Browse files Browse the repository at this point in the history
  • Loading branch information
cokelaer committed Oct 6, 2023
1 parent 94643a7 commit 6c60828
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
strategy:
max-parallel: 5
matrix:
python: [3.8, 3.9, '3.10']
python: [3.8, 3.9, '3.10', '3.11']
fail-fast: false

steps:
Expand Down
17 changes: 8 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,15 @@ Versionix
.. image:: https://github.com/sequana/versionix/actions/workflows/main.yml/badge.svg
:target: https://github.com/sequana/versionix/actions/workflows/main.yml

.. image:: https://coveralls.io/repos/github/sequana/versionix/badge.svg?branch=master
:target: https://coveralls.io/github/sequana/versionix?branch=master

.. image:: http://readthedocs.org/projects/versionix/badge/?version=latest
:target: http://versionix.readthedocs.org/en/latest/?badge=latest
:alt: Documentation Status
.. image:: https://coveralls.io/repos/github/sequana/versionix/badge.svg?branch=main
:target: https://coveralls.io/github/sequana/versionix?branch=main

.. image:: https://zenodo.org/badge/658721856.svg
:target: https://zenodo.org/badge/latestdoi/658721856

:Python version: Python 3.8, 3.9, 3.10
:Python version: Python 3.8, 3.9, 3.10, 3.11
:Source: See `http://github.com/sequana/versionix <https://github.com/sequana/versionix/>`__.
:Issues: Please fill a report on `github <https://github.com/sequana/versionix/issues>`__
:Platform: This is currently only available for Linux distribution with bash shell (contributions are welcome to port the tool on MacOSX and other platforms)

Overview
========
Expand All @@ -36,12 +31,16 @@ If you are in a hurry, just type::

pip install versionix --upgrade

This is pure Python so no need for fancy libraries of fancy environment.
This is pure Python so no need for fancy libraries.

Then, just type e.g::

versionix fastqc

This tool uses a registry so it will work only with resgistered tools, which list can be obtained with::

versionix --registered

DESCRIPTION
===========

Expand Down
3 changes: 3 additions & 0 deletions test/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ def test_script(fp, mocker):
result = runner.invoke(main, ["bedtools"])
print(result)

runner.invoke(main, ["--registered"])
runner.invoke(main, ["--stats"])
runner.invoke(main, )

def test_bedtools_error(fp, mocker):
# registered tool but if not installed, should raise a SystemExit error
Expand Down
27 changes: 24 additions & 3 deletions versionix/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
###########################################################################
""".. rubric:: Standalone application dedicated to Damona"""
import click
import sys


from versionix import version
Expand All @@ -33,12 +34,32 @@


@click.command()
@click.argument("standalone", required=True, type=click.STRING)
@click.argument("standalone", required=False, type=click.STRING, default=None)
@click.version_option(version)
@click.option("--stats", is_flag=True, help="Prints number of registered tools")
@click.option("--registered", is_flag=True, help="Prints the list of registered tools")
def main(**kwargs):
"""Versionix returns the version of installed software.
versionix fastqc
versionix fastqc
You can check the list of registered tools as follows
versionix --registered
"""
print(get_version(kwargs["standalone"]))
if kwargs["stats"]:
from versionix.registry import metadata
click.echo(f"There are currently {len(metadata.keys())} registered tools in Versionix")
elif kwargs["registered"]:
from versionix.registry import metadata
names = sorted(metadata.keys())
for name in names:
click.echo(f"{name}")
else:
if kwargs["standalone"] is None:
click.echo("No standalone was provided. You must provide one. You can use --registered to see the current list'")
sys.exit(1)
else:
click.echo(get_version(kwargs["standalone"]))

0 comments on commit 6c60828

Please sign in to comment.