From ab9ffabbd2800d33ee8878ec8f0b796bac241b22 Mon Sep 17 00:00:00 2001 From: G Johansson Date: Wed, 3 Jul 2024 19:47:56 +0000 Subject: [PATCH] Fix console script --- README.md | 23 +++++++++++++---------- pyproject.toml | 2 +- pytrafikverket/__init__.py | 6 ++++++ 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 16e71b5..8e539aa 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ python module for communicating with the swedish trafikverket api Development and testing done with 3.11 ## Code example + ```python from pytrafikverket import TrafikverketTrain, StationInfo import aiohttp @@ -34,14 +35,16 @@ loop.run_until_complete(main(loop)) ``` ## CLI example -```bash -$ py pytrafikverket.py -key -method search-for-station -station "Kristianstad" -$ py pytrafikverket.py -key -method get-next-train-stop -from-station "Kristianstad C" -to-station "Sölvesborg" -$ py pytrafikverket.py -key -method get-next-train-stop -from-station "Kristianstad C" -to-station "Sölvesborg" -train-product "SJ Regional" -$ py pytrafikverket.py -key -method get-train-stop -from-station "Kristianstad C" -to-station "Sölvesborg" -date-time "2017-05-19T16:38:00" -$ py pytrafikverket.py -key -method get-weather -station "Nöbbele" -$ py pytrafikverket.py -key -method search-for-ferry-route -route "sund" -$ py pytrafikverket.py -key -method get-ferry-route -route "Adelsöleden" -$ py pytrafikverket.py -key -method get-next-ferry-stop -from-harbor "Ekerö" -$ py pytrafikverket.py -key -method get-next-ferry-stop -from-harbor "Furusund" -date-time "2019-12-24T00:00:00" + +```python +trafikverket_cli -key -method search-for-station -station "Kristianstad" +trafikverket_cli -key -method get-next-train-stop -from-station "Kristianstad C" -to-station "Sölvesborg" +trafikverket_cli -key -method get-next-train-stop -from-station "Kristianstad C" -to-station "Sölvesborg" -train-product "SJ Regional" +trafikverket_cli -key -method get-train-stop -from-station "Kristianstad C" -to-station "Sölvesborg" -date-time "2017-05-19T16:38:00" +trafikverket_cli -key -method get-weather -station "Nöbbele" +trafikverket_cli -key -method search-for-ferry-route -route "sund" +trafikverket_cli -key -method get-ferry-route -route "Adelsöleden" +trafikverket_cli -key -method get-next-ferry-stop -from-harbor "Ekerö" +trafikverket_cli -key -method get-next-ferry-stop -from-harbor "Furusund" -date-time "2019-12-24T00:00:00" ``` + diff --git a/pyproject.toml b/pyproject.toml index e27479d..f0164a2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,7 +28,7 @@ packages = [ ] [tool.poetry.scripts] -pytrafikverket = "pytrafikverket:main" +trafikverket_cli = "pytrafikverket:run" [tool.poetry.dependencies] python = "^3.11" diff --git a/pytrafikverket/__init__.py b/pytrafikverket/__init__.py index 01f6484..ce251d2 100644 --- a/pytrafikverket/__init__.py +++ b/pytrafikverket/__init__.py @@ -29,3 +29,9 @@ TrafikverketTrain, ) from .trafikverket_weather import TrafikverketWeather + +from .__main__ import main + + +def run() -> None: + main()