run method
Runs this command.
The return value is wrapped in a Future if necessary and returned by
CommandRunner.runCommand.
Implementation
@override
void run() async {
List<String> args = argResults!.rest;
// Show usage if no arguments are provided.
showUsage(args.isEmpty, () => printUsage());
// Get the repository URL from the command line arguments.
final remote = args[0];
// Get the slug and local directory for the repository.
final slug = remote.slugify();
final localDirectory = await Repositories.dir(slug, create: false);
// If the local directory is a git repository, delete it.
if (await XPM.isGit(localDirectory)) {
await localDirectory.delete(recursive: true);
}
// Remove the repository from the database.
final db = await DB.instance();
await db.writeTxn(() async {
return await db.repos.where().urlEqualTo(remote).deleteAll();
});
// Display a success message.
out("{@green}Repo removed from the list of repos{@end}");
}