remove the console command

This commit is contained in:
James
2020-03-06 13:34:37 +00:00
parent 3ab51ccff9
commit 7f2b819861
5 changed files with 48 additions and 377 deletions

View File

@@ -1,22 +0,0 @@
<?php
namespace JHodges\Sitemap;
use Symfony\Component\Console\Application;
class ConsoleApplication extends Application
{
public function __construct()
{
error_reporting(-1);
parent::__construct('Sitempa', '0.1.0');
$this->add(new CrawlCommand());
}
public function getLongVersion()
{
return parent::getLongVersion().' by <comment>JHodges</comment>';
}
}

View File

@@ -1,54 +0,0 @@
<?php
namespace JHodges\Sitemap;
use GuzzleHttp\RequestOptions;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ConfirmationQuestion;
class CrawlCommand extends Command
{
protected function configure()
{
$this->setName('crawl')
->setDescription('Crawl and generate sitemap for the website.')
->addArgument(
'url',
InputArgument::REQUIRED,
'The url to check'
)->addOption(
'found-on',
'f',
InputOption::VALUE_NONE,
'Display found on URLs'
);
}
/**
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
*
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$baseUrl = $input->getArgument('url');
$crawler=new Crawler([RequestOptions::CONNECT_TIMEOUT => 60, RequestOptions::TIMEOUT => 60]);
$crawler->crawl($baseUrl);
foreach($crawler->getResults() as $url=>$result){
$output->writeln("{$result['code']} {$url}");
if($input->getOption('found-on')){
foreach($result['foundOn'] as $url=>$count){
$output->writeln(" -> ($count) $url");
}
}
}
return 0;
}
}