Skip to content

Commit

Permalink
ref: CLI's commands
Browse files Browse the repository at this point in the history
  • Loading branch information
theus77 committed Dec 27, 2023
1 parent d6d5c77 commit 6028d7a
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 23 deletions.
9 changes: 6 additions & 3 deletions elasticms-cli/src/Command/Document/DocumentUpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@
use EMS\CommonBundle\Common\Admin\AdminHelper;
use EMS\CommonBundle\Common\Command\AbstractCommand;
use EMS\CommonBundle\Contracts\File\FileReaderInterface;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

#[AsCommand(
name: Commands::DOCUMENTS_UPDATE,
description: 'Update documents from excel or csv file with custom configuration.',
hidden: false
)]
final class DocumentUpdateCommand extends AbstractCommand
{
private string $configFile;
Expand All @@ -26,8 +32,6 @@ final class DocumentUpdateCommand extends AbstractCommand
private bool $dataSkipFirstRow;
private bool $dryRun;

protected static $defaultName = Commands::DOCUMENTS_UPDATE;

private const ARGUMENT_DATA_FILE = 'data-file';
private const ARGUMENT_CONFIG_FILE = 'config-file';
private const OPTION_DATA_OFFSET = 'data-offset';
Expand All @@ -43,7 +47,6 @@ public function __construct(private readonly AdminHelper $adminHelper, private r
protected function configure(): void
{
$this
->setDescription('Update documents from excel or csv file with custom configuration')
->addArgument(self::ARGUMENT_CONFIG_FILE, InputArgument::REQUIRED, 'Config file (json)')
->addArgument(self::ARGUMENT_DATA_FILE, InputArgument::REQUIRED, 'Data file (excel or csv)')
->addOption(self::OPTION_DATA_OFFSET, null, InputOption::VALUE_REQUIRED, 'Offset data', 0)
Expand Down
8 changes: 6 additions & 2 deletions elasticms-cli/src/Command/File/AuditFileCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,21 @@
use App\CLI\Commands;
use EMS\CommonBundle\Common\Command\AbstractCommand;
use EMS\Helpers\File\File;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Logger\ConsoleLogger;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Mime\MimeTypes;

#[AsCommand(
name: Commands::FILE_AUDIT,
description: 'Audit files in a folder structure.',
hidden: false
)]
class AuditFileCommand extends AbstractCommand
{
protected static $defaultName = Commands::FILE_AUDIT;
final public const UPPERCASE_EXTENSION = 'ExtensionWithUppercase';
final public const EXTENSION_MISMATCH = 'ExtensionMismatch';

Expand All @@ -37,7 +42,6 @@ public function __construct()
protected function configure(): void
{
$this
->setDescription('Audit files in a folder structure')
->addArgument(
self::ARG_FOLDER,
InputArgument::REQUIRED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,20 @@
use EMS\CommonBundle\Common\Command\AbstractCommand;
use EMS\CommonBundle\Contracts\File\FileReaderInterface;
use EMS\CommonBundle\Search\Search;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;

#[AsCommand(
name: Commands::FILE_READER_IMPORT,
description: 'Import an Excel file or a CSV file, one document per row.',
hidden: false
)]
final class FileReaderImportCommand extends AbstractCommand
{
protected static $defaultName = Commands::FILE_READER_IMPORT;

private const ARGUMENT_FILE = 'file';
private const ARGUMENT_CONTENT_TYPE = 'content-type';
private const OPTION_OUUID_EXPRESSION = 'ouuid-expression';
Expand All @@ -44,7 +48,6 @@ public function __construct(private readonly AdminHelper $adminHelper, private r
protected function configure(): void
{
$this
->setDescription('Import an Excel file or a CSV file, one document per row')
->addArgument(self::ARGUMENT_FILE, InputArgument::REQUIRED, 'File path (xlsx or csv)')
->addArgument(self::ARGUMENT_CONTENT_TYPE, InputArgument::REQUIRED, 'Content type target')
->addOption(self::OPTION_DRY_RUN, null, InputOption::VALUE_NONE, 'Just do a dry run')
Expand Down
9 changes: 6 additions & 3 deletions elasticms-cli/src/Command/MediaLibrary/LoadTikaCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@
use App\CLI\Commands;
use App\CLI\Helper\Tika\TikaHelper;
use EMS\CommonBundle\Common\Command\AbstractCommand;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Finder\Finder;

#[AsCommand(
name: Commands::MEDIA_LIBRARY_TIKA_CACHE,
description: 'Generate a tika cache from files in a given folder.',
hidden: false
)]
final class LoadTikaCache extends AbstractCommand
{
protected static $defaultName = Commands::MEDIA_LIBRARY_TIKA_CACHE;

private const ARGUMENT_FOLDER = 'folder';
private const ARGUMENT_TIKA_CACHE_FOLDER = 'tika-cache-folder';
private string $folder;
Expand All @@ -24,7 +28,6 @@ final class LoadTikaCache extends AbstractCommand
protected function configure(): void
{
$this
->setDescription('Generate a tika cache from files in a given folder')
->addArgument(self::ARGUMENT_FOLDER, InputArgument::REQUIRED, 'Folder path')
->addArgument(self::ARGUMENT_TIKA_CACHE_FOLDER, InputArgument::REQUIRED, 'Folder where tika extraction can be cached')
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@
use EMS\CommonBundle\Common\Command\AbstractCommand;
use EMS\CommonBundle\Contracts\ExpressionServiceInterface;
use EMS\CommonBundle\Contracts\File\FileReaderInterface;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

#[AsCommand(
name: Commands::MEDIA_LIBRARY_SYNC,
description: 'Synchronization files on media library for a given folder.',
hidden: false
)]
final class MediaLibrarySyncCommand extends AbstractCommand
{
protected static $defaultName = Commands::MEDIA_LIBRARY_SYNC;

private const ARGUMENT_FOLDER = 'folder';
private const OPTION_CONTENT_TYPE = 'content-type';
private const OPTION_FOLDER_FIELD = 'folder-field';
Expand Down Expand Up @@ -56,7 +60,6 @@ public function __construct(
protected function configure(): void
{
$this
->setDescription('Synchronization files on media library for a given folder')
->addArgument(self::ARGUMENT_FOLDER, InputArgument::REQUIRED, 'Folder path')
->addOption(self::OPTION_CONTENT_TYPE, null, InputOption::VALUE_OPTIONAL, 'Media Library content type (default: media_file)', 'media_file')
->addOption(self::OPTION_FOLDER_FIELD, null, InputOption::VALUE_OPTIONAL, 'Media Library folder field (default: media_folder)', 'media_folder')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@
use App\CLI\Client\Photos\PhotosLibraryInterface;
use App\CLI\Commands;
use EMS\CommonBundle\Common\Admin\AdminHelper;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

#[AsCommand(
name: Commands::APPLE_PHOTOS_MIGRATION,
description: 'Migrate Apple Photo library to elaticms documents.',
hidden: false
)]
class ApplePhotosMigrationCommand extends AbstractPhotosMigrationCommand
{
protected static $defaultName = Commands::APPLE_PHOTOS_MIGRATION;

final public const ARG_PHOTOS_LIBRARY_PATH = 'photos-library-path';
private string $applePhotosPathPath;

Expand All @@ -25,7 +29,6 @@ public function __construct(AdminHelper $adminHelper)
protected function configure(): void
{
$this
->setDescription('Migrate Apple Photo library to elaticms documents')
->addArgument(
self::ARG_PHOTOS_LIBRARY_PATH,
InputArgument::REQUIRED,
Expand Down
9 changes: 6 additions & 3 deletions elasticms-cli/src/Command/Web/AuditCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,20 @@
use EMS\CommonBundle\Contracts\CoreApi\Endpoint\Data\DataInterface;
use EMS\CommonBundle\Elasticsearch\Document\EMSSource;
use EMS\Helpers\Standard\Json;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Logger\ConsoleLogger;
use Symfony\Component\Console\Output\OutputInterface;

#[AsCommand(
name: Commands::WEB_AUDIT,
description: 'Audit (security headers, content, locale, accessibility) website.',
hidden: false
)]
class AuditCommand extends AbstractCommand
{
protected static $defaultName = Commands::WEB_AUDIT;

private const ARG_URL = 'url';
private const OPTION_CONTINUE = 'continue';
private const OPTION_CACHE_FOLDER = 'cache-folder';
Expand Down Expand Up @@ -77,7 +81,6 @@ public function __construct(private readonly AdminHelper $adminHelper)
protected function configure(): void
{
$this
->setDescription('Audit (security headers, content, locale, accessibility) website')
->addArgument(
self::ARG_URL,
InputArgument::REQUIRED,
Expand Down
9 changes: 6 additions & 3 deletions elasticms-cli/src/Command/Web/MigrationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,20 @@
use EMS\CommonBundle\Common\Admin\AdminHelper;
use EMS\CommonBundle\Common\Command\AbstractCommand;
use EMS\Helpers\Standard\Json;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Logger\ConsoleLogger;
use Symfony\Component\Console\Output\OutputInterface;

#[AsCommand(
name: Commands::WEB_MIGRATION,
description: 'Migration web resources to elaticms documents.',
hidden: false
)]
class MigrationCommand extends AbstractCommand
{
protected static $defaultName = Commands::WEB_MIGRATION;

private const ARG_CONFIG_FILE_PATH = 'json-path';
private const OPTION_CONTINUE = 'continue';
private const ARG_OUUID = 'OUUID';
Expand Down Expand Up @@ -51,7 +55,6 @@ public function __construct(private readonly AdminHelper $adminHelper)
protected function configure(): void
{
$this
->setDescription('Migration web resources to elaticms documents')
->addArgument(
self::ARG_CONFIG_FILE_PATH,
InputArgument::REQUIRED,
Expand Down

0 comments on commit 6028d7a

Please sign in to comment.