diff options
author | Fbenas <philbeansburton@gmail.com> | 2020-06-07 03:09:35 +0100 |
---|---|---|
committer | Fbenas <philbeansburton@gmail.com> | 2020-06-07 03:09:35 +0100 |
commit | 37594ccdf6581d669045e097114be37d221dba24 (patch) | |
tree | 95e78a51857e5e56be74ca31b7ef1a5a275b374a | |
parent | 8cd1dfe6acea4b5cd87b72cb951197a91d6026c1 (diff) |
First pass at making an IRC compatiable warapper to taskwarrior
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | composer.json | 26 | ||||
-rw-r--r-- | scripts/irc.php | 10 | ||||
-rw-r--r-- | src/IRC/Application.php | 47 |
4 files changed, 85 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3a9875b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/vendor/ +composer.lock diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..353ee5f --- /dev/null +++ b/composer.json @@ -0,0 +1,26 @@ +{ + "name": "fbeans/blatask", + "authors": [ + { + "name": "Fbenas", + "email": "philbeansburton@gmail.com" + } + ], + "require": { + "fbeans/blairc": "0.1", + "symfony/process": "^5.2@dev", + "symfony/console": "^5.2" + }, + "autoload": { + "psr-4": { + "FBeans\\Blatask\\": "src/" + } + }, + "repositories": [ + { + "type": "vcs", + "url": "https://www.blatech.co.uk/FBeans/blairc.git" + } + ], + "minimum-stability": "dev" +} diff --git a/scripts/irc.php b/scripts/irc.php new file mode 100644 index 0000000..172ed29 --- /dev/null +++ b/scripts/irc.php @@ -0,0 +1,10 @@ +<?php + +require __DIR__.'/../vendor/autoload.php'; + +use FBeans\Blatask\IRC\Application; + +$app = (new Application) + ->fromStdin() + ->toConsole() + ->run(); diff --git a/src/IRC/Application.php b/src/IRC/Application.php new file mode 100644 index 0000000..4bb6d71 --- /dev/null +++ b/src/IRC/Application.php @@ -0,0 +1,47 @@ +<?php + +namespace FBeans\Blatask\IRC; + +use FBeans\BlaIRC\Command; +use FBeans\BlaIRC\Application As BlaApplication; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Process\Process; + +class Application extends BlaApplication +{ + public function command(): Command + { + $command = new Command; + $command->setName('task:list'); + + // argument 0 is the command name + $command->addArgument(1); + + $command->setExecuteCallback( + function (InputInterface $input, OutputInterface $output) { + $filter = $input->getArgument(1); + + $process_argument = ["task", "list"]; + + if ($filter) { + $process_argument[] = $filter; + } + + $process = new Process($process_argument); + + $process->run(); + + if (!$process->isSuccessful()) { + $output->write($process->getErrorOutput()); + return Command::SUCCESS; + } + + $output->write($process->getOutput()); + return Command::FAILURE; + } + ); + + return $command; + } +} |