code-lts/cli-tools 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

code-lts/cli-tools

最新稳定版本:v1.6.0

Composer 安装命令:

composer require code-lts/cli-tools

包简介

CLI tools to manage output errors formatting for junit, checkstyle, teamcity, gitlab and github error formats

README 文档

README

codecov Version License

CLI tools to manage output errors formatting for junit, checkstyle, teamcity, gitlab and github error formats.

Motivation

Have formatters that I can re-use in projects to format errors. Some code is copied from phpstan. See #4122

Example usages

Format errors

use CodeLts\CliTools\Error;
use CodeLts\CliTools\AnalysisResult;
use CodeLts\CliTools\OutputFormat;
use CodeLts\CliTools\Exceptions\FormatNotFoundException;

// if the value is from an user input
// Will throw FormatNotFoundException
// See valid formats at OutputFormat::VALID_OUTPUT_FORMATS
OutputFormat::checkOutputFormatIsValid('notValidFormat');

$fileSpecificErrors = [
    new Error(
        'My error message',
        '/file/path/to/File.php',
        15 // Line number
    ),
];

$notFileSpecificErrors = [
    'Just an error message',
];

$internalErrors = [
    'Oops the internal engine did crash !',
];

$warnings = [
    'I warn you that most of this code is tested',
    'Contributions are very welcome',
];

$analysisResult = new AnalysisResult(
    $fileSpecificErrors,
    $notFileSpecificErrors,
    $internalErrors,
    $warnings
);

OutputFormat::displayUserChoiceFormat(
    OutputFormat::OUTPUT_FORMAT_TABLE,// The phpstan table error format, you can have a lot more formats in OutputFormat::VALID_OUTPUT_FORMATS
    $analysisResult,
    $this->sourceRootDirectory,// can be null, if null the error paths will not be pretty and will be displayed as given
    $this->output // Implement CodeLts\CliTools\Output or use CodeLts\CliTools\Symfony\SymfonyOutput
);

Read/Write files

use CodeLts\CliTools\File\FileReader;
use CodeLts\CliTools\File\FileWriter;

$fileName = 'myFile.txt';

FileWriter::write(
    $fileName,
    'Some data, blob, blob, blob.'
);

FileReader::read($fileName);// -> Some data, blob, blob, blob.

ANSI codes

use CodeLts\CliTools\File\AnsiEscapeSequences;

$this->output->writeFormatted(AnsiEscapeSequences::ERASE_TO_LINE_END);

Detect a CI

use CodeLts\CliTools\Utils;

// See supported CIs at https://github.com/OndraM/ci-detector#supported-continuous-integration-servers

Utils::isCiDetected(); // true of false

统计信息

  • 总下载量: 87.52k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MPL-2.0
  • 更新时间: 2020-11-25