55use Symfony \Component \Console \Command \Command ;
66use Symfony \Component \Console \Input \InputInterface ;
77use Symfony \Component \Console \Output \OutputInterface ;
8- use Symfony \Component \Console \Helper \ProgressBar ;
9- use TextAnalysis \Downloaders \DownloadPackageFactory as DPF ;
108use 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}
0 commit comments