Closed abdulwahid closed 2 years ago
@abdulwahid
We support options to configure them in your example, use the following code
This will create a log:demo --startDate=2022-04-19 --endDate=2022-04-21
command
'Demo Log' => [
'run' => 'log:demo --startDate={startDate} --endDate={endDate}',
'type' => 'primary',
'group' => 'Text',
'variables' => [
[
'label' => 'startDate',
'field' => 'date',
],
[
'label' => 'endDate',
'field' => 'date',
]
],
],
@stepanenko3
Thanks for your quick response.
But this combination doesn't seem to be possible in Laravel command signature.
Every option or argument must be enclosed in curly braces, we can't define --startDate=
without curly braces in command signature.
The example you provided throws error:
The "--startDate" option does not exist.
because it tries to find {--startDate}
in command signature which we don't have, we have it without braces --startDate
.
@stepanenko3 Can I create a PR to for this support?
@abdulwahid,
Yes, it will be great if you open a PR
@stepanenko3
I am unable to push my branch because of permissions.
ERROR: Permission to stepanenko3/nova-command-runner.git denied to abdulwahid.
fatal: Could not read from remote repository.
In src/Dto/CommandDto.php
:
I changed from:
$command->setParsedCommand(
str_replace('{'.$variable['label'].'}', $variable['value'], $command->getParsedCommand() )
);
to:
if (strpos($variable['label'], '--') !== false) {
$variableName = explode('=', $variable['label'])[0];
$command->setParsedCommand(
str_replace('{'.$variable['label'].'}', $variableName . '=' .$variable['value'], $command->getParsedCommand() )
);
} else {
$command->setParsedCommand(
str_replace('{' . $variable['label'] . '}', $variable['value'], $command->getParsedCommand())
);
}
@stepanenko3
Hi @stepanenko3 ! Any plans to add this or adjust the repo permissions so a PR can be made?
@nathan-io, @abdulwahid I released new version 4.0.11, which implements this
Thank you! 🙌
Hi,
Thank you for this awesome package.
I just wanted to ask if you are planning to add support for command
options
as well viavariables
soon. Thevariables
work perfectly when used for commandarguments
but not foroptions
.We have a scenario in which we are using command
options
to take start date and end date. Sample command:Now in config, if we simply add following:
It takes input value for
--startDate
and--endDate
, but we also need to append prefix--startDate=
and--endDate=
with date values to make it work.Also we can't use
field => "date"
in this scenario, which is usable if we would have been usingarguments
.