Added install command

Added the install command.
	- Implemented run method.
	- A list of candidates to install is determined.
	- Basic implementation side loads packages
This commit is contained in:
Ethan Smith-Coss 2023-08-09 14:07:49 +01:00
parent c8848aec47
commit 82a7224190
Signed by: TheOnePath
GPG Key ID: 4E7D436CE1A0BAF1

View File

@ -0,0 +1,43 @@
import clog
import pathlib
import argparse
import soypak.cli.command as command
import soypak.deps.transaction as transaction # :@Note: future use
import soypak.deps.bottler as bottler
_log = clog.Logger.get("runtime_logger")
@command.register_command(name="install", help=command.CommandHelpStruct(
synopsis="Install debian binary packages.",
usage="install <package1> [<package2>, ..., <packagen>]",
summary=("Install one or multiple available packages via soypak."))
)
class Install(command.Command):
def __init__(self, *, data: argparse.Namespace, args: list[str] = []) -> None:
super().__init__()
self.data = data
self.rargs = args
def run(self):
candidates: list[bottler.Soybottle] = []
# any preinit before installing should occur here
for item in self.rargs:
# has a Debian file been directly passed?
if item.endswith(".bottle") and pathlib.Path(item).resolve().exists():
_log.debug("Detected a bottle file. Considering sidingloading...")
# let's structure the file to be processed.
pkg = bottler.loadPackage(item)
if pkg is None:
# :@Ethan: maybe the loadPackage could give us some information.
raise Exception(f"Unable to load {item}.")
_log.debug(f"Sideloading: {item}").withConsole()
candidates.append(pkg)
continue
# let's check the database for a package by the given name
...