Make output more configurable

Do only output success in the end.
Allow to output more info based on verbosity.
This commit is contained in:
danielsiepmann 2020-10-03 16:31:46 +02:00 committed by Daniel Siepmann
parent 9ec70df7bc
commit 93c22ce548
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4

View file

@ -54,25 +54,33 @@ class Command
$cutting = new Cutting($videoInfo);
$this->io->title('Generating temp cutted video files.');
$this->executeStep('Generating temp cutted video files.');
foreach ($cutting->getCommandsForCutting() as $command) {
$this->runCommand($command);
}
$this->io->title('Generating Metadata');
$this->runCommand($cutting->getCommandForGeneratingMetadata());
$this->executeStep(
'Generating Metadata',
$cutting->getCommandForGeneratingMetadata()
);
$this->io->title('Generating Concat input file');
$this->runCommand($cutting->getCommandForGeneratingConcatInputFile());
$this->executeStep(
'Generating Concat input file',
$cutting->getCommandForGeneratingConcatInputFile()
);
$this->io->title('Creating target folder');
$this->executeStep('Creating target folder');
$this->createTargetFolder($videoInfo);
$this->io->title('Generating final video');
$this->runCommand($cutting->getCommandForGeneratingVideo());
$this->executeStep(
'Generating final video',
$cutting->getCommandForGeneratingVideo()
);
$this->io->title('Cleanup');
$this->runCommand($cutting->getCommandForCleanup());
$this->executeStep(
'Cleanup',
$cutting->getCommandForCleanup()
);
$this->io->success(sprintf(
'Generated video file "%s".',
@ -82,16 +90,29 @@ class Command
return 0;
}
private function executeStep(string $name, Process $command = null): void
{
if ($this->io->isVerbose()) {
$this->io->writeln($name);
}
if ($command instanceof Process) {
$this->runCommand($command);
}
}
private function runCommand(Process $command): void
{
if ($this->io->isVeryVerbose()) {
$this->io->comment('Executing command');
$this->io->comment($command->getCommandLine());
}
$this->io->writeln('Executing command');
$this->io->writeln($command->getCommandLine());
$command->run(function ($type, $buffer) {
$this->io->writeln($buffer);
});
$command->run(function ($type, $buffer) {
$this->io->writeln($buffer);
});
} else {
$command->run();
}
if (!$command->isSuccessful()) {
throw new ProcessFailedException($command);