Files
nextcloud-recognize/lib/Command/DownloadModels.php
Marcel Klehr d3625422cb fix(psalm): Upgrade to psalm 6 and fix issues
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
2025-04-09 13:06:24 +02:00

54 lines
1.3 KiB
PHP

<?php
/*
* Copyright (c) 2022 The Recognize contributors.
* This file is licensed under the Affero General Public License version 3 or later. See the COPYING file.
*/
declare(strict_types=1);
namespace OCA\Recognize\Command;
use OCA\Recognize\Service\DownloadModelsService;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
final class DownloadModels extends Command {
private DownloadModelsService $downloader;
public function __construct(DownloadModelsService $downloader) {
parent::__construct();
$this->downloader = $downloader;
}
/**
* Configure the command
*
* @return void
*/
protected function configure() {
$this->setName('recognize:download-models')
->setDescription('Download the necessary machine learning models');
}
/**
* Execute the command
*
* @param InputInterface $input
* @param OutputInterface $output
*
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output): int {
try {
$this->downloader->download();
} catch (\Exception $ex) {
$output->writeln('<error>Failed to download models</error>');
$output->writeln($ex->getMessage());
return 1;
}
return 0;
}
}