#string #command-line-tool #pretty #cli

app line_grub

一款处理那些不幸地很长的单行文本文件的命令行工具

3 个版本

0.1.2 2022年9月29日
0.1.1 2022年9月29日
0.1.0 2022年9月29日

#2166命令行工具

MIT/Apache

8KB

line_grub

line_grub 是一款小巧的命令行工具,旨在减轻处理 不幸地 很长的字符串的痛苦。无论它们在哪里。

比如这些

A neutron star is the collapsed core of a massive supergiant star, which had a total mass of between 10 and 25 solar masses, possibly more if the star was especially metal-rich. Neutron stars are the smallest and densest stellar objects, excluding black holes and hypothetical white holes, quark stars, and strange stars.[2] Neutron stars have a radius on the order of 10 kilometres (6.2 mi) and a mass of about 1.4 solar masses. They result from the supernova explosion of a massive star, combined with gravitational collapse, that compresses the core past white dwarf star density to that of atomic nuclei.

哎呀...

说明

非常简单。将其安装到您的路径中,输入以下命令...

line_grub long_string_file.txt output.txt

您将得到这个

A neutron star is the collapsed core of a massive supergiant star, which had a total mass of between 10 and 25 solar masses, possibly more if the star was especially metal-rich.
Neutron stars are the smallest and densest stellar objects, excluding black holes and hypothetical white holes, quark stars, and strange stars.[2] Neutron stars have a radius on the order of 10 kilometres (6.2 mi) and a mass of about 1.4 solar masses.
They result from the supernova explosion of a massive star, combined with gravitational collapse, that compresses the core past white dwarf star density to that of atomic nuclei. 

好多了,不是吗?

如果您想在字符串的任何位置添加4个空格的制表符,只需在字符串的任何位置添加 "\"。例如

\A neutron star is the collapsed core of a massive supergiant star, which had a total mass of between 10 and 25 solar masses, possibly more if the star was especially metal-rich. Neutron stars are the smallest and densest stellar objects, excluding black holes and hypothetical white holes, quark stars, and strange stars.[2] Neutron stars have a radius on the order of 10 kilometres (6.2 mi) and a mass of about 1.4 solar masses.

然后您将得到这个!

    A neutron star is the collapsed core of a massive supergiant star, which had a total mass of between 10 and 25 solar masses, possibly more if the star was especially metal-rich.
Neutron stars are the smallest and densest stellar objects, excluding black holes and hypothetical white holes, quark stars, and strange stars.[2] Neutron stars have a radius on the order of 10 kilometres (6.2 mi) and a mass of about 1.4 solar masses.

大多数文本编辑器都有很好的自动换行功能。所以实际上,在没有这个工具的情况下您在很多情况下也会过得很好。但是,当您纯粹在命令行上时,它可能很有用!它对调试也有帮助。

使用 line_grub

line_grub 可在 crates.io 上找到。目前使用它的方法是使用 Cargo。我很快会添加可执行文件。

cargo install line_grub

line_grub 目前需要 rustc 1.46.0 或更高版本。

贡献

line_grub 是一个极其新的开源项目!请注意,提交给 line_grub 的所有代码都假定遵循 line_grub 的双 MIT/Apache2 许可。

许可

line_grub 在 MIT 许可和 Apache 许可(版本 2.0)的条款下分发。有关详细信息,请参阅 LICENSE-APACHELICENSE-MIT。提交拉取请求被视为接受这些许可条款。

依赖

~1.3–1.9MB
~35K SLoC