Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix standard-names entry point #17

Merged
merged 5 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
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
14 changes: 6 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,15 @@ jobs:

steps:
- uses: actions/checkout@v4

- uses: conda-incubator/setup-miniconda@v2
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
miniforge-variant: Miniforge3
miniforge-version: latest
auto-update-conda: true

- name: Install package and testing dependencies
run: |
pip install .[dev,test]
run: pip install nox

- name: Test
run: nox -s test
run: |
nox -s test
nox -s test-cli
14 changes: 13 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
PYTHON_VERSION = "3.12"


@nox.session(python=PYTHON_VERSION, venv_backend="conda")
@nox.session
def test(session: nox.Session) -> None:
"""Run the tests."""
session.install(".[peg,testing]")
Expand All @@ -26,6 +26,18 @@ def test(session: nox.Session) -> None:
session.run("coverage", "report", "--ignore-errors", "--show-missing")


@nox.session(name="test-cli")
def test_cli(session: nox.Session) -> None:
"""Test the cli."""
session.install(".[peg]")

session.run("standard-names", "--help")
session.run("standard-names", "--version")
for cmd in ("build", "dump", "scrape", "sql", "validate"):
session.run("standard-names", cmd, "--help")
session.run("standard-names", cmd)


@nox.session
def lint(session: nox.Session) -> None:
"""Look for lint."""
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ docs = [
]

[project.scripts]
"standard-names" = "standard_names.cmd.main:main"
"standard-names" = "standard_names.cli.main:main"

[build-system]
requires = [
Expand Down
2 changes: 1 addition & 1 deletion src/standard_names/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.2.8.dev0"
__version__ = "0.2.9.dev0"
9 changes: 7 additions & 2 deletions src/standard_names/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@ def _add_cmd(name: str, *, help: str) -> argparse.ArgumentParser:
"file", type=argparse.FileType("r"), nargs="*", help="Read names from a file"
)
dump_parser.add_argument(
"--field", "-f", action="append", help="Fields to print", choices=VALID_FIELDS
"--field",
"-f",
action="append",
default=[],
help="Fields to print",
choices=VALID_FIELDS,
)
dump_parser.add_argument(
"--sort", action=argparse.BooleanOptionalAction, help="Sort/don't sort names"
Expand Down Expand Up @@ -120,7 +125,7 @@ def build(args: argparse.Namespace) -> int:


def dump(args: argparse.Namespace) -> int:
fields = [VALID_FIELDS[field] for field in args.field] or None
fields = [VALID_FIELDS[field] for field in args.field]

registry = NamesRegistry([])
for file in args.file:
Expand Down