1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 10:37:45 +00:00

pkg: Parse dependencies as part of the main port entry

The "dependency" lines really belong to the main port entry, it doesn't
make sense logically to represent them separately and handling them
together will also allow easier dependency management later on. This
commit greatly simplifies the port database parsing to facilitate this,
and removes the -d option from the command line. Instead, ports are
listed with their dependencies, if they have any.
This commit is contained in:
kleines Filmröllchen 2023-10-04 12:33:54 +02:00 committed by Tim Schumacher
parent a5f566c2c6
commit 05af549bad
4 changed files with 56 additions and 44 deletions

View file

@ -17,15 +17,15 @@ class InstalledPort {
public:
enum class Type {
Auto,
Dependency,
Manual,
};
static Optional<Type> type_from_string(StringView);
static ErrorOr<HashMap<String, InstalledPort>> read_ports_database();
static ErrorOr<void> for_each_by_type(HashMap<String, InstalledPort>&, Type type, Function<ErrorOr<void>(InstalledPort const&)> callback);
InstalledPort(String name, Type type, String version)
: m_name(name)
: m_name(move(name))
, m_type(type)
, m_version(move(version))
{
@ -36,8 +36,6 @@ public:
{
if (m_type == Type::Auto)
return "Automatic"sv;
if (m_type == Type::Dependency)
return "Dependency"sv;
if (m_type == Type::Manual)
return "Manual"sv;
VERIFY_NOT_REACHED();
@ -45,9 +43,11 @@ public:
StringView name() const { return m_name.bytes_as_string_view(); }
StringView version() const { return m_version.bytes_as_string_view(); }
ReadonlySpan<String> dependencies() const { return m_dependencies.span(); }
private:
String m_name;
Type m_type;
String m_version;
Vector<String> m_dependencies;
};