2026-04-13 06:12:04 +00:00
|
|
|
#!/usr/bin/env php
|
|
|
|
|
<?php
|
|
|
|
|
/* Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
|
|
|
|
*
|
|
|
|
|
* This file is part of a Moko Consulting project.
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
*
|
|
|
|
|
* FILE INFORMATION
|
2026-05-31 12:14:34 -05:00
|
|
|
* DEFGROUP: MokoPlatform.Scripts.Fix
|
|
|
|
|
* INGROUP: MokoPlatform
|
2026-05-11 17:01:17 -05:00
|
|
|
* REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
|
2026-04-15 02:35:30 +00:00
|
|
|
* PATH: /fix/fix_line_endings.php
|
2026-05-31 12:14:34 -05:00
|
|
|
* BRIEF: CLI script to normalise CRLF/CR to LF in tracked source files
|
2026-04-13 06:12:04 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2026-05-31 12:14:34 -05:00
|
|
|
require_once __DIR__ . '/../vendor/autoload.php';
|
|
|
|
|
require_once __DIR__ . '/../lib/Enterprise/CliFramework.php';
|
2026-04-13 06:12:04 +00:00
|
|
|
|
2026-05-31 12:14:34 -05:00
|
|
|
use MokoEnterprise\CliFramework;
|
2026-04-13 06:12:04 +00:00
|
|
|
use MokoEnterprise\FileFixUtility;
|
|
|
|
|
|
2026-05-31 12:14:34 -05:00
|
|
|
class FixLineEndings extends CliFramework
|
2026-04-13 06:12:04 +00:00
|
|
|
{
|
2026-05-31 12:14:34 -05:00
|
|
|
protected function configure(): void
|
|
|
|
|
{
|
|
|
|
|
$this->setDescription('Normalise CRLF/CR to LF in tracked source files');
|
|
|
|
|
$this->addArgument('--path', 'Repository root (default: current directory)', '.');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function run(): int
|
|
|
|
|
{
|
|
|
|
|
$path = (string) $this->getArgument('--path');
|
|
|
|
|
$files = FileFixUtility::fixLineEndings($path, $this->dryRun);
|
|
|
|
|
|
|
|
|
|
foreach ($files as $f) {
|
|
|
|
|
$this->status(true, "Fixed: {$f}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$label = $this->dryRun ? 'Would fix' : 'Fixed';
|
|
|
|
|
$this->log("{$label} " . count($files) . ' file(s)');
|
|
|
|
|
return self::EXIT_SUCCESS;
|
|
|
|
|
}
|
2026-04-13 06:12:04 +00:00
|
|
|
}
|
|
|
|
|
|
2026-05-31 12:14:34 -05:00
|
|
|
$app = new FixLineEndings();
|
|
|
|
|
exit($app->execute());
|