-
-
Notifications
You must be signed in to change notification settings - Fork 50
Description
hello hello! Thank you for creating babi as well as for all of your other educational material! I've been using babi and was wondering about a possible new feature which would (optionally) populate the editor with template text when creating a new file. After looking through the source code, here is one idea I've come up with for how this might be implemented.
- Add an optional command line argument indicating whether to use a template (and if so which. only applicable if no filename is given or if the given filename doesn't exist)
- Pass that argument along to the File.ensure_loaded method.
- In the case where the passed filename does not exist or filename is None, instead of passing the empty string to get_lines, call a function which returns a string to pass in based on that command line argument (and perhaps other info).
- Create
babi/resources/templates.pywhich will:
a. Store various text templates
b. Contain the function referenced in 3.
If we think there would reasonably be only one template per file extension, then I'd lean toward making the command line argument a flag and then parse the filename to determine which flag to use. Then we could have something like babi t.py --template yielding
If not, then I think the command line argument would need to indicate which template to use.
I'd be very interested in hearing your thoughts. Thanks for your time and consideration!
