Init consolidation
The init subcommand includes a lot of logic that could probably be offloaded to other parts of the code. Particularly so that the implementation can be shared between the CLI and the new gui work.
-
The sync function in portmod/sync.py
could handle adding repositories and take a BaseRepo instead of a Repo.- This is basically already done by the sync subcommand in
portmod/_cli/sync.py
.
- This is basically already done by the sync subcommand in
-
Repo should probably be renamed to LocalRepo to make the Local/Remote distinction better. -
add_prefix should probably also take a profile and maybe an initial set of repositories. -
set_profile
needs to be a separate function so that the profile can be changed, but we shouldn't let prefixes be initialized without one.
-
-
add_prefix should be as atomic as possible to reduce the chance that an error will produce a partially initialized prefix. -
add_prefix should update the index for the new prefix once it's been created - If we're choosing a profile before the prefix is created, then the sync will occur before prefix creation and not update the index for the new prefix.
- This will mean updating the index updating function to optionally take a prefix as an argument, as currently they can only be updated together.
- It might be worth revisiting how the index is structured, as ideally the index should be based on the repository, not prefix, but I don't think tantivy allows searching from multiple indexes simultaneously.
-
init should run the initial world update automatically to pull in the system packages. This is mentioned in the setup guide, but I've seen people overlook it and it makes sense to have init handle as much as it can. -
In the manner of the other initial operations, it should use this opportunity to introduce the user to the idea of a world update.
-
Edited by Benjamin Winger