Hi there,
I'm working at a company that needs to add some features to julia's pkg manager. Specifically, we want to be able to 1) install packages from an arbitrary REQUIRE file and 2) include git URIs in REQUIRE files. Rather than just taking on these features we thought we might do some refactoring to make the API a little cleaner.
For point 1 we currently have a method called `addrequire` that adds the entries from a REQUIRE file to the global REQUIRE file and calls resolve. While the approach seems reasonable I personally don't like the name `addrequire`, so here is my refactoring proposal to address that.
- `Pkg.add` should just add a requirement to the global REQUIRE file without doing a resolve. This method should dispatch on a String (package name), URI (remote git uri) and a Path type
- If the type is a String we check that it is a registered package name and add it to the global REQUIRE file.
- If the type is a URI we check it and also write it to the global REQUIRE file.
- if the type is a Path and is a REQUIRE file (`isfile(...)`) add all entries in REQUIRE file, and if the path is a directory (`isdir(...)`) search for a REQUIRE file.
- `Pkg.install` should be a wrapper around `Pkg.add` and `Pkg.resolve` and it should also dispatch on the above types and behave in the same way.
Pros:
- Better utilization of multiple dispatch to help with code & API clarity. Might also help with modularity of `Pkg` in base, but I'd have to dig into the code more.
- Layered API given that `install` is just a wrapper to `add` and `resolve`
- Allows installing packages from arbitrary files not just pkg REQUIRE files.
Cons:
- API change (the existing `Pkg.add` is essentially renamed to `Pkg.install`)
- Currently would require a URI type and a Path type, which are currently in external packages.
Does this seem reasonable? Do people have other suggestions or ideas?
Thanks,
Rory