-
-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use mnapoli/silly for cli applications #279
Conversation
not required, but silences EA notice. From official documentation: Note: For portability, it is strongly recommended that you always use the 'b' flag when opening files with fopen(). Note: Again, for portability, it is also strongly recommended that you re-write code that uses or relies upon the 't' mode so that it uses the correct line endings and 'b' mode instead.
increases readability
this is still mess, but perhaps better
note the commandline syntax changed now requires email:download to be as first argument also support for executing from web has been dropped. if need to execute from web, create your own wrapper.
➔ rgrep -r const.DEFAULT_COMMAND src/Command/|nf|LC_ALL=C sort 'extension:enable'; 'mail-queue:process'; 'mail-queue:truncate'; 'mail:download'; 'mail:route'; 'reminders:check'; 'system:monitor';
Due the way Symfony\Console works, scripts that use non-option arguments, their invocation has been changed. Commands that used only options or none, for them it was possible to setup default command to be run without arguments. For these invocation has not changed.
UPATE: this is no longer valid, see #279 (comment) |
perhaps should just have single entrypoint for those cli commands (except bin/upgrade.php and bin/irc-bot.php because they are different) and deprecate current ones. what the name would be?
|
looks like with symfony/console 3.2 it's possible to enable http://symfony.com/doc/3.2/components/console/single_command_tool.html and given that example don't even need silly library much (ok, it does provide DI and simple interface to define all arguments and options): #!/usr/bin/env php
<?php
require __DIR__.'/vendor/autoload.php';
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
(new Application('echo', '1.0.0'))
->register('echo')
->addArgument('foo', InputArgument::OPTIONAL, 'The directory')
->addOption('bar', null, InputOption::VALUE_REQUIRED)
->setCode(function(InputInterface $input, OutputInterface $output) {
// output arguments and options
})
->getApplication()
->setDefaultCommand('echo', true) // Single command application
->run(); so just need to add the |
seems to require symfony/console 3.2 eventum#279 (comment)
seems to require symfony/console 3.2 eventum#279 (comment)
Sorry I didn't get a chance to review this right away but I think it is all good. Our cli scripts have been rather painful. I like the idea of a single entrypoint as well for a future improvement, |
My suggestion is:
bin/process_jobs.php
I also like the idea of consolidating.. would be even better if we could
process multiple commands from one cron job.
Eg. bin/process_jobs.php mail:download ... mail:send reminders:process etc..
bin/process_jobs.php mail:downloadall (no arguments needed, processes all
active accounts)
Craig.
…On Sun, Sep 10, 2017 at 10:17 PM, Bryan Alsdorf ***@***.***> wrote:
Sorry I didn't get a chance to review this right away but I think it is
all good. Our cli scripts have been rather painful.
I like the idea of a single entrypoint as well for a future improvement,
bin/eventum.php would be my first choice.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#279 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AKnrsbsIGT8dDZHY1CUidXy9V2kL7NLbks5shJg1gaJpZM4OlsGe>
.
|
dislikes:
processing multiple commands, i had this idea too, but mostly because i invoke same command repeatedly for different projects in serial manner:
@balsdorf the cli scripts haven't been pain since 3.0.9 (Feb 6, 2016, #137), i.e they were organized into |
Good point on @cpinfold You actually can run multiple commands in one cronjob, just separate the commands with a ';'.
|
Thanks Bryan.. hadn't thought of doing it that way.
+1 for command.php
It would also be nice to call:
bin/command.php download:all
or bin/command.php mail:downloadall
And let it go through all the accounts. I have a few accounts checked less
frequently, but wouldn't if I could call one command.
Craig.
…On Mon, Sep 18, 2017 at 10:56 AM, Bryan Alsdorf ***@***.***> wrote:
Good point on bin/eventum.php. Django uses manage.py but I can see how
that wouldn't always be appropriate. I'm fine with console.php,
command.php or manage.php but I don't think any name is going to be 100%
accurate unfortunately.
@cpinfold <https://github.com/cpinfold> You actually can run multiple
commands in one cronjob, just separate the commands with a ';'.
* * * * * bin/download_emails.php ***@***.*** example.org INBOX.support; bin/download_emails.php ***@***.*** example.org INBOX
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#279 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AKnrsczuIKDA48n2JpuDOYxaSK-21vbEks5sjoSEgaJpZM4OlsGe>
.
|
requires symfony/console ^3.2.0 eventum/eventum#279 (comment)
We have Symfony\Console as dependency since introduction of Phinx.
For long time wanted to convert the console scripts using Symfony\Console, they were even moved to classes (#137) with having in mind porting to Symfony\Console one day.
So today found Silly CLI micro-framework based on Symfony Console. and couldn't resist.
Symfony\Console benefits:
--verbose
,--quiet
)probably could easily add debug messages with verbose increasing. currently no script is able to print more information if wanted to debug script execution.
new library dependencies: