44#include < QJsonDocument>
55#include < QJsonArray>
66#include < QJsonObject>
7+ #include < QFile>
78#include < iostream>
89
910#include " package_manager_lib.h"
@@ -114,24 +115,46 @@ int cmdList(PackageManagerLib& pm, const QString& category, bool installedOnly,
114115 return 0 ;
115116}
116117
118+ int cmdInstallFile (PackageManagerLib& pm, const QString& filePath) {
119+ if (!QFile::exists (filePath)) {
120+ err << " Error: file not found: " << filePath << Qt::endl;
121+ return 1 ;
122+ }
123+
124+ out << " Installing from file: " << filePath << " ..." << Qt::flush;
125+
126+ QString errorMsg;
127+ QString installedPath = pm.installPluginFile (filePath, errorMsg);
128+
129+ if (installedPath.isEmpty ()) {
130+ out << " FAILED" << Qt::endl;
131+ err << " Error: " << errorMsg << Qt::endl;
132+ return 1 ;
133+ }
134+
135+ out << " done" << Qt::endl;
136+ out << " Installed to: " << installedPath << Qt::endl;
137+ return 0 ;
138+ }
139+
117140int cmdInstall (PackageManagerLib& pm, const QStringList& args) {
118141 if (args.isEmpty ()) {
119142 err << " Error: install requires at least one package name" << Qt::endl;
120143 return 1 ;
121144 }
122-
145+
123146 out << " Resolving dependencies..." << Qt::endl;
124147 QStringList packagesToInstall = pm.resolveDependencies (args);
125-
126- out << " Will install " << packagesToInstall.size () << " package(s): "
148+
149+ out << " Will install " << packagesToInstall.size () << " package(s): "
127150 << packagesToInstall.join (" , " ) << Qt::endl << Qt::endl;
128-
151+
129152 int installed = 0 ;
130153 int failed = 0 ;
131-
154+
132155 for (const QString& packageName : packagesToInstall) {
133156 out << " Installing: " << packageName << " ..." << Qt::flush;
134-
157+
135158 if (pm.installPackage (packageName)) {
136159 out << " done" << Qt::endl;
137160 installed++;
@@ -140,7 +163,7 @@ int cmdInstall(PackageManagerLib& pm, const QStringList& args) {
140163 failed++;
141164 }
142165 }
143-
166+
144167 out << Qt::endl;
145168 if (failed == 0 ) {
146169 out << " Done. " << installed << " package(s) installed successfully." << Qt::endl;
@@ -223,6 +246,7 @@ void printHelp() {
223246 out << " search <query> Search packages by name or description" << Qt::endl;
224247 out << " list List all available packages" << Qt::endl;
225248 out << " install <pkg> [pkgs...] Install one or more packages" << Qt::endl;
249+ out << " install --file <path> Install from a local LGX file" << Qt::endl;
226250 out << " categories List available categories" << Qt::endl;
227251 out << " info <package> Show detailed package information" << Qt::endl;
228252 out << Qt::endl;
@@ -231,6 +255,7 @@ void printHelp() {
231255 out << " --ui-plugins-dir <path> Set UI plugins directory" << Qt::endl;
232256 out << " --category <cat> Filter by category (for list command)" << Qt::endl;
233257 out << " --installed Show only installed packages (for list command)" << Qt::endl;
258+ out << " --file <path> Install from a local LGX file (for install command)" << Qt::endl;
234259 out << " --json Output in JSON format" << Qt::endl;
235260 out << " -h, --help Show this help message" << Qt::endl;
236261 out << " -v, --version Show version information" << Qt::endl;
@@ -252,14 +277,16 @@ int main(int argc, char *argv[]) {
252277 QCommandLineOption categoryOption (" category" , " Filter by category" , " category" );
253278 QCommandLineOption installedOption (" installed" , " Show only installed packages" );
254279 QCommandLineOption jsonOption (" json" , " Output in JSON format" );
255-
280+ QCommandLineOption fileOption (" file" , " Install from a local LGX file path" , " path" );
281+
256282 parser.addOption (helpOption);
257283 parser.addOption (versionOption);
258284 parser.addOption (pluginsDirOption);
259285 parser.addOption (uiPluginsDirOption);
260286 parser.addOption (categoryOption);
261287 parser.addOption (installedOption);
262288 parser.addOption (jsonOption);
289+ parser.addOption (fileOption);
263290 parser.addPositionalArgument (" command" , " Command to run" );
264291 parser.addPositionalArgument (" args" , " Command arguments" , " [args...]" );
265292
@@ -302,6 +329,9 @@ int main(int argc, char *argv[]) {
302329 bool installedOnly = parser.isSet (installedOption);
303330 return cmdList (pm, category, installedOnly, jsonOutput);
304331 } else if (command == " install" ) {
332+ if (parser.isSet (fileOption)) {
333+ return cmdInstallFile (pm, parser.value (fileOption));
334+ }
305335 return cmdInstall (pm, positionalArgs);
306336 } else if (command == " categories" ) {
307337 return cmdCategories (pm, jsonOutput);
0 commit comments