Skip to content

Commit

Permalink
Use entry points for subcommand discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
timj committed Nov 27, 2024
1 parent 66e634d commit 0031bd7
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ lsstcam/CALIB/calibRegistry.sqlite3
lsstcam/CALIB/qe_curve/
.vscode/
.coverage*
python/*.dist-info/
7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
[project]
name = "lsst-obs-lsst"

[project.entry-points.'butler.cli']
obs_lsst = "lsst.obs.lsst.cli:get_cli_subcommands"

[tool.ruff]
line-length = 110
target-version = "py311"
Expand Down Expand Up @@ -32,4 +38,3 @@ max-doc-length = 79

[tool.ruff.lint.pydocstyle]
convention = "numpy"

1 change: 1 addition & 0 deletions python/lsst/obs/lsst/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from ._get_cli_subcommands import get_cli_subcommands
37 changes: 37 additions & 0 deletions python/lsst/obs/lsst/cli/_get_cli_subcommands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This file is part of obs_lsst.
#
# Developed for the LSST Data Management System.
# This product includes software developed by the LSST Project
# (http://www.lsst.org).
# See the COPYRIGHT file at the top-level directory of this distribution
# for details of code ownership.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

__all__ = ["get_cli_subcommands"]

import click

from . import cmd


def get_cli_subcommands() -> list[click.Command]:
"""Return the location of the CLI command plugin definitions.
Returns
-------
commands : `list` [ `click.Command` ]
The command-line subcommands provided by this package.
"""
return [getattr(cmd, c) for c in cmd.__all__]
2 changes: 2 additions & 0 deletions python/lsst/obs/lsst/cli/cmd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

__all__ = ["ingest_photodiode", "ingest_guider"]

from .commands import (
ingest_photodiode,
ingest_guider,
Expand Down
5 changes: 0 additions & 5 deletions python/lsst/obs/lsst/cli/resources.yaml

This file was deleted.

1 change: 0 additions & 1 deletion ups/obs_lsst.table
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ setupRequired(meas_algorithms)

envPrepend(PYTHONPATH, ${PRODUCT_DIR}/python)
envPrepend(PATH, ${PRODUCT_DIR}/bin)
envPrepend(DAF_BUTLER_PLUGINS, ${PRODUCT_DIR}/python/lsst/obs/lsst/cli/resources.yaml)

0 comments on commit 0031bd7

Please sign in to comment.