Skip to content

Commit

Permalink
Remove "vendor" command as not that practical and too specific (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Aug 18, 2023
1 parent d6962fe commit b88cd01
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 288 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/code_analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ jobs:
# try json output
bin/lines measure src --json --ansi
-
name: 'Run "vendor" command'
run: |
bin/lines vendor --ansi
-
name: 'PHPStan'
run: composer phpstan --ansi
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"symfony/finder": "^6.3",
"illuminate/container": "^10.16",
"webmozart/assert": "^1.11",
"nikic/php-parser": "^4.16",
"nikic/php-parser": "^4.17",
"sebastian/lines-of-code": "^2.0",
"nunomaduro/termwind": "^1.15"
},
Expand Down
6 changes: 2 additions & 4 deletions src/Console/Command/MeasureCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ protected function configure(): void
);

$this->addOption('json', null, InputOption::VALUE_NONE, 'Output in JSON format');

// @todo
$this->addOption('short', null, InputOption::VALUE_NONE, 'Print short metrics only');
}

Expand All @@ -68,9 +66,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int

// print results
if ($isJson) {
$this->jsonOutputFormatter->printMeasurement($measurement, $output, $isShort);
$this->jsonOutputFormatter->printMeasurement($measurement, $isShort);
} else {
$this->textOutputFormatter->printMeasurement($measurement, $output, $isShort);
$this->textOutputFormatter->printMeasurement($measurement, $isShort);
}

return Command::SUCCESS;
Expand Down
103 changes: 0 additions & 103 deletions src/Console/Command/VendorCommand.php

This file was deleted.

101 changes: 0 additions & 101 deletions src/Console/Loading.php

This file was deleted.

5 changes: 2 additions & 3 deletions src/Console/OutputFormatter/JsonOutputFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@

namespace TomasVotruba\Lines\Console\OutputFormatter;

use Symfony\Component\Console\Output\OutputInterface;
use TomasVotruba\Lines\Contract\OutputFormatterInterface;
use TomasVotruba\Lines\Measurements;
use Webmozart\Assert\Assert;

final class JsonOutputFormatter implements OutputFormatterInterface
{
public function printMeasurement(Measurements $measurements, OutputInterface $output, bool $isShort): void
public function printMeasurement(Measurements $measurements, bool $isShort): void
{
$arrayData = [
'filesystem' => [
Expand Down Expand Up @@ -58,6 +57,6 @@ public function printMeasurement(Measurements $measurements, OutputInterface $ou
$jsonString = json_encode($arrayData, JSON_PRETTY_PRINT);
Assert::string($jsonString);

$output->writeln($jsonString);
echo $jsonString;
}
}
23 changes: 10 additions & 13 deletions src/Console/OutputFormatter/TextOutputFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,40 @@

namespace TomasVotruba\Lines\Console\OutputFormatter;

use Symfony\Component\Console\Output\OutputInterface;
use TomasVotruba\Lines\Console\View;
use TomasVotruba\Lines\Console\ViewRenderer;
use TomasVotruba\Lines\Contract\OutputFormatterInterface;
use TomasVotruba\Lines\Helpers\NumberFormat;
use TomasVotruba\Lines\Measurements;

final class TextOutputFormatter implements OutputFormatterInterface
{
public function __construct(
private readonly View $view
private readonly ViewRenderer $viewRenderer
) {
}

public function printMeasurement(Measurements $measurements, OutputInterface $output, bool $isShort): void
public function printMeasurement(Measurements $measurements, bool $isShort): void
{
$this->view
->setOutput($output)
->newLine();
$this->viewRenderer->newLine();

$this->printFilesAndDirectories($measurements);
$this->printLinesOfCode($measurements);

if ($isShort) {
$this->view->newLine();
$this->viewRenderer->newLine();

return;
}

$this->printStructure($measurements);
$this->printMethods($measurements);

$this->view->newLine();
$this->viewRenderer->newLine();
}

private function printFilesAndDirectories(Measurements $measurements): void
{
$this->view->render('table', [
$this->viewRenderer->render('table', [
'title' => 'Metric',
'label' => 'Count',
'rows' => $this->formatRows([
Expand All @@ -52,7 +49,7 @@ private function printFilesAndDirectories(Measurements $measurements): void

private function printLinesOfCode(Measurements $measurements): void
{
$this->view->render('table', [
$this->viewRenderer->render('table', [
'title' => 'Lines of code',
'label' => 'Count',
'includeRelative' => true,
Expand All @@ -70,7 +67,7 @@ private function printMethods(Measurements $measurements): void
return;
}

$this->view->render('table', [
$this->viewRenderer->render('table', [
'title' => 'Methods',
'label' => 'Count',
'includeRelative' => true,
Expand All @@ -87,7 +84,7 @@ private function printMethods(Measurements $measurements): void

private function printStructure(Measurements $measurements): void
{
$this->view->render('table', [
$this->viewRenderer->render('table', [
'title' => 'Structure',
'label' => 'Count',
'rows' => $this->formatRows([
Expand Down
Loading

0 comments on commit b88cd01

Please sign in to comment.