Compare commits

...

2 Commits

Author SHA1 Message Date
cc90f9719b Prepared dynamic field delete command.
Some checks failed
continuous-integration/drone/push Build is failing
2023-10-10 18:57:05 +02:00
04a2a6adcb Differentiated between options and arguments in dynamic field add command. 2023-10-10 18:56:37 +02:00
2 changed files with 42 additions and 42 deletions

View File

@ -38,55 +38,48 @@ sub Configure {
my ( $Self, %Param ) = @_; my ( $Self, %Param ) = @_;
$Self->Description('Create a new dynamic field.'); $Self->Description('Create a new dynamic field.');
$Self->AddOption( $Self->AddArgument(
Name => 'name', Name => 'name',
Description => 'Name for the new field.', Description => 'Name for the new field.',
Required => 1, Required => 1,
HasValue => 1,
ValueRegex => qr/[A-Za-z0-9]+/smx, ValueRegex => qr/[A-Za-z0-9]+/smx,
); );
$Self->AddOption( $Self->AddArgument(
Name => 'label', Name => 'label',
Description => 'Label which will be displayed alongside the field.', Description => 'Label which will be displayed alongside the field.',
Required => 1, Required => 1,
HasValue => 1,
ValueRegex => qr/.*/smx, ValueRegex => qr/.*/smx,
); );
$Self->AddOption( $Self->AddArgument(
Name => 'field-type', Name => 'field-type',
Description => 'Dynamic field type.', Description => 'Dynamic field type.',
Required => 1, Required => 1,
HasValue => 1,
ValueRegex => qr/[A-Za-z0-9]/smx, ValueRegex => qr/[A-Za-z0-9]/smx,
); );
$Self->AddOption( $Self->AddArgument(
Name => 'object-type', Name => 'object-type',
Description => 'Object type for the new field.', Description => 'Object type for the new field.',
Required => 1, Required => 1,
HasValue => 1,
ValueRegex => qr/[A-Za-z0-9]/smx, ValueRegex => qr/[A-Za-z0-9]/smx,
); );
$Self->AddOption( $Self->AddArgument(
Name => 'config', Name => 'config',
Description => Description =>
'Config for dynamic field. Takes either an YAML or JSON string. See also Admin::DynamicField::ConfigDump and Admin::DynamicField::ConfigBuild.', 'Config for dynamic field. Takes either an YAML or JSON string. See also Admin::DynamicField::ConfigDump and Admin::DynamicField::ConfigBuild.',
Required => 0, Required => 0,
HasValue => 1,
ValueRegex => qr/.*/smx, ValueRegex => qr/.*/smx,
); );
$Self->AddOption( $Self->AddArgument(
Name => 'namespace', Name => 'namespace',
Description => 'Namespace to place the new field into.', Description => 'Namespace to place the new field into.',
Required => 0, Required => 0,
HasValue => 1,
ValueRegex => qr/[A-Za-z0-9]+/smx, ValueRegex => qr/[A-Za-z0-9]+/smx,
); );
$Self->AddOption( $Self->AddArgument(
Name => 'field-order', Name => 'field-order',
Description => Description =>
'Field order to place the field at. Defaults to hightest order plus 1. Per default, other fields are reordered if an occupied order number is chosen.', 'Field order to place the field at. Defaults to hightest order plus 1. Per default, other fields are reordered if an occupied order number is chosen.',
Required => 0, Required => 0,
HasValue => 1,
ValueRegex => qr/\d+/smx, ValueRegex => qr/\d+/smx,
); );
$Self->AddOption( $Self->AddOption(
@ -96,11 +89,10 @@ sub Configure {
HasValue => 1, HasValue => 1,
ValueRegex => qr/^[[0-1]{1}$/smx, ValueRegex => qr/^[[0-1]{1}$/smx,
); );
$Self->AddOption( $Self->AddArgument(
Name => 'valid', Name => 'valid',
Description => 'Whether the field to add is valid or invalid. Defaults to 1.', Description => 'Whether the field to add is valid or invalid. Defaults to 1.',
Required => 0, Required => 0,
HasValue => 1,
ValueRegex => qr/^[0-1]{1}$/smx, ValueRegex => qr/^[0-1]{1}$/smx,
); );
$Self->AddOption( $Self->AddOption(

View File

@ -25,40 +25,48 @@ use warnings;
# OTOBO modules # OTOBO modules
our @ObjectDependencies = ( use parent qw(Kernel::System::Console::BaseCommand);
our @ObjectDependencies = (
'Kernel::System::DynamicField',
); );
=head1 NAME sub Configure {
my ( $Self, %Param ) = @_;
[name_placeholder] $Self->Description('Delete an existing dynamic field.');
$Self->AddArgument(
Name => 'name',
Description => 'Delete dynamic field by name.',
Required => 0,
ValueRegex => qr/([A-Za-z0-9]+\-)?[A-Za-z0-9]+/smx,
);
$Self->AddArgument(
Name => 'id',
Description => 'Delete dynamic field by field id.',
Required => 0,
ValueRegex => qr/\d+/smx,
);
$Self->AddOption(
Name => 'dry-run',
Description => 'Perform a dry run and show which field whould be deleted.',
Required => 0,
HasValue => 0,
);
$Self->AddOption(
Name => 'execute',
Description => 'Execute the deletion.',
Required => 0,
HasValue => 0,
);
=head1 DESCRIPTION return;
[description_placeholder]
=head1 PUBLIC INTERFACE
=head2 new()
create an object. Do not use it directly, instead use:
my $DeleteObject = $Kernel::OM->Get('Kernel::System::Console::Command::Admin::DynamicField::Delete');
=cut
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {%Param};
bless( $Self, $Type );
return $Self;
} }
sub Run { sub Run {
my ( $Self, %Param ) = @_; my ( $Self, %Param ) = @_;
return;
} }
1; 1;