Hi all,
over in the other thread by @gdalle I suggested that his tutorials could include a small generator for startup.jl
files with some common configurations like Revise.jl, OhMyREPL.jl, PkgTemplates.jl. He suggested that this could be useful for everyone not just newcomers so I quickly threw together this small package: StartupCustomizer.jl
Design ideas
- Easy to use: Ideally this should be a “batteries included” type of package.
- Extensibility: I only have 3 things in my startup.jl but other people might know of more handy things, so it should be easy to add new things.
API
You can use status()
to see what currently is in your startup.jl, list()
to get a list of available modules, describe(module)
to get detailed information on a module, add(module...)
/remove(module...)
to add/remove modules and edit()
to edit the startup.jl directly by hand. Notably add
ing modules also installs required packages into the global default environment.
I have implemented examples for Revise.jl
, OhMyREPL.jl
and PkgTemplates.jl
because I am personally using these three.
How things work
The main concept of this package is that of a StartupModule
which handles something you want to put into your startup.jl. All one needs to do to add something new is to make a subtype of AbstractStartupModule
and implement 4 methods short_description
, long_description
, _dependencies
and _generate
.
For add
,remove
,status
, this package scans startup.jl
to determine what it has written there previously. Only parts that are recognized are ever altered. This package marks section by wrapping them in comments like # begin StartupCustomizer.Revise()
and # end StartupCustomizer.Revise()
. These comments also serve as storage for the parameters of the modules, so modules should take care that they are reconstructable from their string representation.
Now I’d like to hear some feedback from you all:
- The name: At first I thought to call it just
Startup.jl
because that is what this package is concerned with and if it grows into the default way of managing startup files maybe it’s not such a bad name after all. It could be confusing (when does someone talk about the package, when about the file?) and I think it is not my place to give it such a general name. - Do you have suggestions how to achieve its goal better/make it more robust? Right now I am writing comment lines into startup.jl to mark out the blocks. I also put the configuration of the modules there in stringform. This is clunky (because everything is written to string and needs to be reconstructed from a string) and for modules with more configuration (cough
PkgTemplates.jl
cough) becomes somewhat messy but everything is self contained. - I only have Linux and don’t know how to best locate the default
startup.jl
on other platforms. - Speaking of testing… I am unsure how to write meaningful tests for this. Checking the generated file is easy of course but not a good test and I am not sure how to test the behavior of the generated file.
- It would generally be better if the modules could generate Julia code and put that nicely formatted into startup.jl than to generate strings. Any suggestions for a pretty printing library for Julia code?
- General style: I chose not to export the somewhat generic names of this package so they don’t clash with e.g.
InteractiveUtils.edit
. However that leads to rather verbose calls when using it. - Right now we only install required packages into the global environment but never remove them because the user might want them there for something else. Can you think of a better way of handling this?
Any feedback is welcome I am too set on anything here, I made this rather quickly after getting the impulse from @gdalle