Skip to content

Commit

Permalink
feat: kickstart cli
Browse files Browse the repository at this point in the history
  • Loading branch information
js2264 committed Aug 1, 2024
1 parent ef105c5 commit 4b041d2
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 3 deletions.
4 changes: 2 additions & 2 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
API
====

momics.Momics
momics.api
-------------

.. automodule:: momics.Momics
.. automodule:: momics.api
:members:
:undoc-members:
:show-inheritance:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@
# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = "furo"
# html_theme = "pydata_sphinx_theme"
html_static_path = ["_static"]
htmlhelp_basename = "momicsdoc"
html_last_updated_fmt = "%b %d, %Y"
html_title = "momics"
html_theme = "furo"
html_theme_options = {
"source_repository": "https://github.com/js2264/momics/",
"source_branch": "devel",
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ dependencies = [
"numpy",
"pandas",
"pyarrow>=1.0",
"click>=7",
]

[project.urls]
Expand Down
2 changes: 2 additions & 0 deletions src/momics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
"""

from .api import Momics
from .version import __format_version__, __version__

__all__ = [
"__version__",
"__format_version__",
"Momics",
]
File renamed without changes.
27 changes: 27 additions & 0 deletions src/momics/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import click

from ..version import __version__

CONTEXT_SETTINGS = {"help_option_names": ["-h", "--help"]}


class UnsortedGroup(click.Group):
"""A click Group that lists commands in the order they were added."""

def list_commands(self, ctx):
return list(self.commands)


@click.version_option(__version__, "-V", "--version")
@click.group(context_settings=CONTEXT_SETTINGS, cls=UnsortedGroup)
def cli():
"""
Type -h or --help after any subcommand for more information.
"""


# Load and register cli subcommands
from . import ( # noqa: E402,F401
dump,
)
21 changes: 21 additions & 0 deletions src/momics/cli/dump.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import click

from .. import api
from . import cli


@cli.command()
@click.argument("momics", metavar="MOMICS_PATH")
@click.option(
"--table",
"-t",
help="Which table to dump.",
type=click.Choice(["chroms", "tracks"]),
default="chroms",
show_default=True,
)
def dump(momics, table):
if table == "tracks":
print(api.Momics(momics).tracks())
if table == "chroms":
print(api.Momics(momics).chroms())
File renamed without changes.

0 comments on commit 4b041d2

Please sign in to comment.