From 705a352f365f5bfb123be77b7ba74d6e814a24ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20H=C3=A4rter?= Date: Tue, 26 Sep 2023 19:19:22 +0200 Subject: [PATCH] WIP dynamic field list command. --- .../Command/Admin/DynamicField/List.pm | 67 ++++++++++++++----- 1 file changed, 50 insertions(+), 17 deletions(-) diff --git a/Kernel/System/Console/Command/Admin/DynamicField/List.pm b/Kernel/System/Console/Command/Admin/DynamicField/List.pm index 65d7a91..2482b39 100644 --- a/Kernel/System/Console/Command/Admin/DynamicField/List.pm +++ b/Kernel/System/Console/Command/Admin/DynamicField/List.pm @@ -25,27 +25,60 @@ use warnings; # OTOBO modules -our @ObjectDependencies = ( +use parent qw(Kernel::System::Console::BaseCommand); +our @ObjectDependencies = ( + 'Kernel::System::DynamicField', + 'Kernel::System::YAML', + 'Kernel::System::JSON', ); -=head1 NAME +sub Configure { + my ( $Self, %Param ) = @_; -[name_placeholder] - -=head1 DESCRIPTION - -[description_placeholder] - -=head1 PUBLIC INTERFACE - -=head2 new() - -create an object. Do not use it directly, instead use: - -my $ListObject = $Kernel::OM->Get('Kernel::System::Console::Command::Admin::DynamicField::List'); - -=cut + $Self->Description('List existing dynamic fields.'); + $Self->AddOption( + Name => 'field-type', + Description => 'Filter by comma-separated field type(s).', + Required => 0, + HasValue => 1, + ValueRegex => qr/[A-Za-z0-9,]+/smx, + ); + $Self->AddOption( + Name => 'object-type', + Description => 'Filter by comma-separated object type(s).', + Required => 0, + HasValue => 1, + ValueRegex => qr/[A-Za-z0-9,]+/smx, + ); + $Self->AddOption( + Name => 'name-search', + Description => 'Filter by name or part of a name.', + Required => 0, + HasValue => 1, + ValueRegex => qr/[A-Za-z0-9-]+/smx, + ); + $Self->AddOption( + Name => 'active', + Description => 'Filter by active state (0 or 1), default is both.', + Required => 0, + HasValue => 1, + ValueRegex => qr/^[0-1]{1}$/smx, + ); + $Self->AddOption( + Name => 'verbose', + Description => 'If set, result includes complete config, otherwise only names and orders are given.', + Required => 0, + HasValue => 0, + ); + $Self->AddOption( + Name => 'return-structure', + Description => 'Supported return structures are JSON and YAML, default is YAML.', + Required => 0, + HasValue => 1, + ValueRegex => qr/^(JSON)|(YAML)$/smx, + ); +} sub new { my ( $Type, %Param ) = @_;