#cat #wc #cli #unix-shell

bin+lib tpt

Unix cat、wc 和 echo 命令的纯 Rust 实现

5 个不稳定版本

0.3.0 2022年4月17日
0.2.2 2022年4月16日
0.2.1 2022年4月16日
0.2.0 2020年10月1日
0.1.0 2020年9月24日

#1092 in 文本处理

MIT 许可协议

11KB
182

文本处理工具包 (tpt)

文本处理工具包包含了一些流行的 Unix shell 命令(如 cat、wc 和 echo)的简单和轻量级纯 Rust 实现。

安装

通过 cargo 安装

cargo install tpt
tpc --help
tpr --help

或从源码构建

git clone https://github.com/Schmid7k/tpt.git
cd tpt
cargo build --release
./target/release/tpc --help
./target/release/tpr --help
./target/release/tpw --help

tpr

文本处理读取 - 简称 tpr - 是一个类似 cat 的命令行工具

Text Processing Toolkit 0.3.0
By Schmid7k
Pure Rust implementation of the Unix concatenate command (cat)

USAGE:
    tpr [FLAGS] [file]...

FLAGS:
    -h, --help        Prints help information
    -n, --numbered    Print lines numbered
    -V, --version     Prints version information

ARGS:
    <file>...

示例用法

tpr -n faust.txt   This prints everything from the specified file faust.txt with numbered lines to stdout

您也可以从其他命令中读取文本

echo "Hello World" | tpr

tpc

文本处理计数 - 简称 tpc - 是一个类似 wc 的命令行工具

Text Processing Toolkit 0.3.0
By Schmid7k
Pure Rust implementation of the Unix wordcount command (wc). Print newline, word, character, and byte counts for each
file or input given through stdin. A word is a non-zero-lenth sequence of character delimited by white space.
The order of counts is always: newline, word, character, byte.

USAGE:
    tpc [FLAGS] [file]...

FLAGS:
    -b, --bytes      Print byte count
    -c, --chars      Print char count
    -h, --help       Prints help information
    -l, --lines      Print line count
    -V, --version    Prints version information
    -w, --words      Print word count

ARGS:
    <file>...

示例用法

tpc -bclw faust.txt   This prints the byte count, char count, line count and word count of the file faust.txt to stdout

您也可以从其他命令中读取文本

echo "Hello World" | tpc -bclw

tpw

文本处理写入 - 简称 tpw - 是一个类似 echo 的命令行工具

Text Processing Toolkit 0.3.0
By Schmid7k
Pure Rust implementation of the Unix echo command

USAGE:
    tpw [FLAGS] [string]

FLAGS:
    -e, --escape     Enable interpretation of backslash escapes
                     \\	backslash
                     \n	newline
                     \r	carriage return
                     \t	horizontal tab
    -h, --help       Prints help information
    -n, --newline    Do not print out the trailing newline
    -V, --version    Prints version information

ARGS:
    <string>

示例用法

tpw "Hello World"

或将输出管道传输到其他命令

tpw "Hello World" | tpc

许可协议

许可协议为 MIT 许可协议。

依赖关系

~3MB
~51K SLoC