feat(sl): add --list flag for available vehicles
This commit is contained in:
parent
fc828c22ca
commit
cb1c89d69d
2 changed files with 26 additions and 0 deletions
|
|
@ -177,6 +177,7 @@ $ sl -s 0.1 # You do not
|
||||||
| `-w` | `--whistle` | Sound the whistle as the train or ship passes |
|
| `-w` | `--whistle` | Sound the whistle as the train or ship passes |
|
||||||
| `-s` | `--speed` | Animation speed multiplier, 0.1–20 (default: 1.0) |
|
| `-s` | `--speed` | Animation speed multiplier, 0.1–20 (default: 1.0) |
|
||||||
| | `--no-color` | Disable colors (`NO_COLOR` is also honored) |
|
| | `--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 |
|
| `-v` | `--version` | Show version information |
|
||||||
| `-h` | `--help` | Show help message |
|
| `-h` | `--help` | Show help message |
|
||||||
|
|
||||||
|
|
|
||||||
25
sl
25
sl
|
|
@ -176,6 +176,14 @@ class Train:
|
||||||
"c51": C51,
|
"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
|
# Wheel animation: (row index, pattern, 4-frame cycle). Each cycle entry
|
||||||
# must be the same width as the pattern it replaces.
|
# must be the same width as the pattern it replaces.
|
||||||
WHEEL_SPEC = {
|
WHEEL_SPEC = {
|
||||||
|
|
@ -348,6 +356,15 @@ class Vessel:
|
||||||
"tug": TUG,
|
"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
|
SIDE_VIEW = ("galleon", "steamer", "sloop") # ride the drawn sea
|
||||||
PERSPECTIVE = ("tug",) # travel their drawn angle
|
PERSPECTIVE = ("tug",) # travel their drawn angle
|
||||||
|
|
||||||
|
|
@ -1038,11 +1055,19 @@ def main():
|
||||||
'clamped to 0.1-20 (default: 1.0)')
|
'clamped to 0.1-20 (default: 1.0)')
|
||||||
parser.add_argument('--no-color', action='store_true',
|
parser.add_argument('--no-color', action='store_true',
|
||||||
help='disable colors (NO_COLOR is also honored)')
|
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',
|
parser.add_argument('-v', '--version', action='version',
|
||||||
version=f'sl version {__version__}')
|
version=f'sl version {__version__}')
|
||||||
|
|
||||||
args = parser.parse_args()
|
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)
|
# Determine what rolls out (or sets sail)
|
||||||
if args.type:
|
if args.type:
|
||||||
craft = args.type
|
craft = args.type
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue