tal7aouy/indent

用于检测和转换字符串和文件中缩进的库。

1.0.0 2022-03-22 11:26 UTC

This package is auto-updated.

Last update: 2024-09-22 16:56:06 UTC


README

用于检测和转换字符串和文件中缩进的库,制表符转换为空格或反之。

⚡️ 安装

通过 composer 安装或直接克隆仓库。

全局安装

使用以下命令全局安装:

composer global require tal7aouy/indent

✅ 使用

./indent
indent [--tabs|--spaces] [-r [--pattern=...]] [files or directories...]

--tabs       convert all indentation to tabs. Assuming 4 spaces tab length.
--spaces     convert all indentation to spaces.

-r           recursively go over all directories given as argument and convert
             files that match --pattern.

--pattern    the pattern to match files for when using -r. Defaults to '*.php'.

--tabstop=N  define number of spaces N to replace a tab with. Defaults to 4.

--help       shows this usage information.

If no file is specified input will be read from STDIN.

🚀 示例

将 STDIN,即 index.php 的内容转换为空格,并打印到 STDOUT

cat index.php | ./indent --spaces

index.php 转换为制表符

indent --tabs index.php

将当前目录中的所有 .php 文件和 LICENSE.md 转换为空格

indent --spaces *.php LICENSE.md

dir 目录中所有 .php 文件转换为制表符(递归)

indent --tabs -r dir

将目录中所有 .md 文件转换为空格(递归)

indent --spaces --pattern=*.md -r dir

indenttal7aouy 创建,并遵循 MIT 许可协议