Skip to content

Commit 65e2fd2

Browse files
fixed text console installer commands
1 parent ffb0fa1 commit 65e2fd2

6 files changed

+22
-24
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"autoload-dev": {
2020
"files": ["tests/TestBaseCase.php"]
2121
},
22-
22+
F
2323
"bin": ["textconsole"],
2424
"require" : {
2525
"php": ">=7.1",

src/Console/Commands/NltkPackageInstallAllCommand.php

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
use Symfony\Component\Console\Command\Command;
66
use Symfony\Component\Console\Input\InputInterface;
77
use Symfony\Component\Console\Output\OutputInterface;
8-
use Symfony\Component\Console\Helper\ProgressBar;
9-
use TextAnalysis\Downloaders\DownloadPackageFactory as DPF;
108
use TextAnalysis\Downloaders\NltkCorporaIndexDownloader;
9+
use Symfony\Component\Console\Input\ArrayInput;
1110

1211

1312
/**
@@ -22,31 +21,23 @@ protected function configure()
2221
->setDescription('Install all packages from pta data');
2322
}
2423

25-
protected function execute(InputInterface $input, OutputInterface $output)
24+
protected function execute(InputInterface $input, OutputInterface $output) : int
2625
{
2726
$listPackages = (new NltkCorporaIndexDownloader())->getPackages();
2827

29-
// create a new progress bar (50 units)
30-
$progress = new ProgressBar($output, count($listPackages));
31-
$progress->setFormat(' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%');
32-
33-
// start and displays the progress bar
34-
$progress->start();
35-
3628
foreach($listPackages as $package)
3729
{
38-
// ... do some work
39-
$progress->setMessage("Downloading {$package->getName()}");
40-
41-
$download = DPF::download($package);
42-
$progress->setMessage("Package {$package->getId()} - {$package->getName()} was installed into {$download->getInstallDir()}");
43-
// advance the progress bar 1 unit
44-
$progress->advance();
45-
30+
$command = $this->getApplication()->find('pta:install:package');
31+
$args = [
32+
'command' => 'pta:install:package',
33+
'package' => $package->getId()
34+
];
35+
36+
$packageInstallerInput = new ArrayInput($args);
37+
$command->run($packageInstallerInput, $output);
4638
}
4739

48-
// ensure that the progress bar is at 100%
49-
$progress->finish();
40+
return 0;
5041
}
5142

5243
}

src/Console/Commands/NltkPackageInstallCommand.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
6161
if(!$packageFound) {
6262
$output->writeln("Package {$packageId} was not found, try textconsole pta:list, to see the available packages");
6363
} else {
64-
65-
$download = DPF::download($package);
64+
65+
$download = DPF::download($package);
66+
$output->writeln("Package {$package->getId()} - {$package->getName()} is being installed into {$download->getInstallDir()}");
6667
// Create stream context.
6768
$context = stream_context_create([], ['notification' => [$this, 'progress']]);
6869

@@ -89,7 +90,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
8990
$download->unpackPackage();
9091
$output->writeln(PHP_EOL);
9192
$output->writeln("Package {$package->getId()} - {$package->getName()} was installed into {$download->getInstallDir()}");
92-
}
93+
$output->writeln(PHP_EOL);
94+
95+
return 0;
96+
}
9397
}
9498

9599
/**

src/Console/Commands/NltkPackageListCommand.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
4646
{
4747
$output->writeln(" * {$package->getId()} - {$package->getName()}");
4848
}
49+
return 0;
4950
}
5051
}

src/Console/Commands/StopWordsCommand.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
6767
}
6868
fclose($stdout);
6969
}
70+
return 0;
7071
}
7172

7273
/**

src/Console/Commands/VocabSizeCommand.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
5050
} else {
5151
throw new \RuntimeException("Please pipe in STDIN");
5252
}
53+
return 0;
5354
}
5455

5556
protected function filter($token)

0 commit comments

Comments
 (0)