updated short version of --next and fixed the help message

This commit is contained in:
Bjornar Orjansen Kaarevik 2024-12-12 23:16:43 +01:00
parent 331d3bb608
commit a07f58551d

View File

@ -6,15 +6,6 @@ from datetime import datetime
from crystal_orb import get_departures from crystal_orb import get_departures
from crystal_orb import STOP_PLACES from crystal_orb import STOP_PLACES
"""
Ideas:
- If time is less than 15 min from now, time text turns red?
- Maybe far-away departures are faint?
- If realtime, then color green
- Different
"""
def pad(s, total_length, justification="l"): def pad(s, total_length, justification="l"):
if len(s) >= total_length: if len(s) >= total_length:
return s[0:total_length] return s[0:total_length]
@ -82,10 +73,23 @@ def print_help_info():
print( print(
"""Help info for the crystal orb cli. """Help info for the crystal orb cli.
Possible commands: Possible commands:
<stop place> : query the api for all busses from the given stop place <stop place>
-h or --help : Show this screen query the api for all busses from the given stop place
--list-stop-places : List the admissible stop places, -h or --help
This is configured in the STOP_PLACES dict in crystal_orb.py""") Show this screen
-l or --list-stop-places
List the admissible stop places.
This is configured in the STOP_PLACES dict in crystal_orb.py
-n or --next
Limit the response to only the next bus matching the query
-b <line> or --bus <line>
Limit the response to only the supplied bus line
-s <place> or --stop <place>
Change the stop place to the supplied place
-t or --to
Limit the response to buses going into town
-f or --from
Limit the response to buses going away from town""")
if __name__ == "__main__": if __name__ == "__main__":
args = sys.argv args = sys.argv
@ -108,7 +112,7 @@ if __name__ == "__main__":
for i, arg in enumerate(args): for i, arg in enumerate(args):
if i == 1 and arg[0] != "-": # First argument is taken as the stop place if i == 1 and arg[0] != "-": # First argument is taken as the stop place
stop_place = arg.lower() stop_place = arg.lower()
elif arg == "--next": # Limits to only giving "the next bus" matching the query elif arg == "-n" or arg == "--next": # Limits to only giving "the next bus" matching the query
take_one = True take_one = True
elif arg == "-b" or arg == "--bus": # Limit to specific bus line elif arg == "-b" or arg == "--bus": # Limit to specific bus line
try: try: