I have been thinking about a new car swap / backup tool, probably DOS based, but I don't know if it'll ever rise near the top of my long list of projects. I shall dump my ideas here, in the hope that they will be useful to someone, one day.
OverviewThe tool I imagine is called CarPark, because yes. When launched without parameters, it shows a text-based interface with a single scrollable list of cars, where each line contains the abbreviation and the full name of a car.
Cars come from both the Stunts directory and a second directory, which acts as backup area. Duplicates are removed, but remembered. If a car is stored in the Stunts directory, and therefore active, there's a symbol at the beginning of its line, for example an
o.
KeysCursor keys and
j/
k can be to move a selection bar up and down the list.
Space acts as toggle to add and remove cars. Press it while the selection is on a car from the Stunts directory, and the
o symbol becomes a
-: the car is marked for removal. You can't mark the last car for removal. Press
Space on a car that is only stored in the parking lot, and a
+ appears on its line: the car is marked for inclusion in the active set. No files have yet moved at this point!
You can also use
a and
d to always add or remove a car. They make it easier to add a bunch of cars without worrying about any already selected cars in the middle of the list:
jajajajaja, in Hungarian style.
The bottom of the screen shows current numbers: active cars, to add, to remove. Next or below that is the list of available keys:
[a] Add [d] Remove [Space] Toggle ....
If the number of cars that are active or to-be-added goes above the maximum allowed (32?), a message appears next to the counters, and saving is disabled.
If the number is OK, pressing
Enter applies the changes: cars with a
+ are copied from the parking lot directory to the Stunts directory; cars with a
- that are *not yet* in the parking lot are moved there. The program could then close, leaving a success message on the prompt.
s could be an alternative key to save without quitting.
Pressing
Escape will close the program, no changes will be applied. There could be a confirmation prompt if the list includes any
+ or
- rows, to avoid losing changes.
Command line optionsIt might be easier to start with these, to have all operations ready in a testable way.
- /backup will copy all cars that are in the Stunts directory but not in the parking lot directory to the latter;
- /backup-all will copy all cars to the parking lot, overwriting any already in there;
- /add NAME [ NAME ...] will look for cars in the parking lot, and copy their files to the Stunts directory; the program will output one line for each car, something like + NAME OK or x NAME Unknown, or x NAME Too Many cars
- /remove NAME [ NAME ... ] will look for car NAME in the Stunts directory, move their files to the parking lot, or moving them there if they don't exist
- /import <directory> will look in the specified directory for full sets of car files, and copy them to the parking lot
- /enable <filename> will read car abbreviations from the file, and copy their files from the parking lot to the Stunts directory; unless all the listed car are missing from the parking lot, it will delete/move all other active cars, leaving only the selected set.
Imagine running
carpark /enable zak-2022.txt and having all cars ready!
NotesThere are operations on multiple files here, that should be handled in a safe and possibly atomic way. Moving car files should copy them, and only delete the original if all four files have been copied successfully.
There are some tricky situations when the two directories contain different versions of the same car, i.e., where some files are compressed in one but not in the other. Overwriting a car should ensure that all files belonging to the previous version are removed. When we check if a car already exists in a directory, we mean "exactly the same files", and might need to skip the car and show a warning.
The tool could include
CAR_<abbreviation>.TXT as an optional file in the set that defines a car. It would be copied around with the rest if it exists. This would give us a vague standard for documentation. Code for an optional file might be a pain to implement though.
(By the way, I've discovered
[ tt ] for monospaced text!)