From cb1c89d69d216271de597954f8c203c17fe93c46 Mon Sep 17 00:00:00 2001 From: "developtheweb@protonmail.com" Date: Fri, 4 Sep 2026 00:12:26 -0400 Subject: [PATCH] feat(sl): add --list flag for available vehicles --- README.md | 1 + sl | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/README.md b/README.md index 9ed3fd6..5ee0c57 100644 --- a/README.md +++ b/README.md @@ -177,6 +177,7 @@ $ sl -s 0.1 # You do not | `-w` | `--whistle` | Sound the whistle as the train or ship passes | | `-s` | `--speed` | Animation speed multiplier, 0.1–20 (default: 1.0) | | | `--no-color` | Disable colors (`NO_COLOR` is also honored) | +| | `--list` | List the available vehicles with a one-line description and exit | | `-v` | `--version` | Show version information | | `-h` | `--help` | Show help message | diff --git a/sl b/sl index 50996fe..0475df1 100755 --- a/sl +++ b/sl @@ -176,6 +176,14 @@ class Train: "c51": C51, } + # One-line descriptions for --list + DESCRIPTIONS = { + "classic": "the classic steam locomotive, no surprises", + "small": "a small locomotive for narrow terminals", + "d51": "D51 locomotive (Japanese style), pulls coal cars with -l", + "c51": "C51 locomotive, the -c engine", + } + # Wheel animation: (row index, pattern, 4-frame cycle). Each cycle entry # must be the same width as the pattern it replaces. WHEEL_SPEC = { @@ -348,6 +356,15 @@ class Vessel: "tug": TUG, } + # One-line descriptions for --list + DESCRIPTIONS = { + "galleon": "three-masted pirate galleon, flapping Jolly Roger, " + "rubber-duck figurehead", + "steamer": "sternwheel steamer whose paddle wheel actually turns", + "sloop": "a racing sloop for narrow terminals", + "tug": "harbor tug in three-quarter perspective, travels diagonally", + } + SIDE_VIEW = ("galleon", "steamer", "sloop") # ride the drawn sea PERSPECTIVE = ("tug",) # travel their drawn angle @@ -1038,11 +1055,19 @@ def main(): 'clamped to 0.1-20 (default: 1.0)') parser.add_argument('--no-color', action='store_true', help='disable colors (NO_COLOR is also honored)') + parser.add_argument('--list', action='store_true', + help='list the available vehicles and exit') parser.add_argument('-v', '--version', action='version', version=f'sl version {__version__}') args = parser.parse_args() + if args.list: + descriptions = {**Train.DESCRIPTIONS, **Vessel.DESCRIPTIONS} + for name in sorted(Train.TRAINS) + sorted(Vessel.VESSELS): + print(f"{name:<8} {descriptions[name]}") + return + # Determine what rolls out (or sets sail) if args.type: craft = args.type