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 bc02349 commit b57f293
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ tests/tmp*
version.py
tests/trivial_camera/qe_curves/ccd00/19700101T000000.ecsv
tests/trivial_camera/qe_curves/ccd00/19800101T000000.ecsv
python/*.dist-info/
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[project.entry-points.'butler.cli']
obs_base = "lsst.obs.base.cli:get_cli_subcommands"

[tool.towncrier]
package = "lsst.obs.base"
package_dir = "python"
Expand Down
1 change: 1 addition & 0 deletions python/lsst/obs/base/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/base/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_base.
#
# 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__]
7 changes: 0 additions & 7 deletions python/lsst/obs/base/cli/resources.yaml

This file was deleted.

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

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

0 comments on commit b57f293

Please sign in to comment.