#line #character #cat #clone #reverse #cargo #nothing

bin+lib khat

A cat clone, nothing more nothing less

5 releases

0.1.4 Dec 5, 2023
0.1.3 Dec 5, 2023
0.1.2 Dec 1, 2023
0.1.1 Nov 30, 2023
0.1.0 Nov 30, 2023

#853 in Text processing

35 downloads per month

MIT license

15KB
248 lines

khat

A cat clone implemented in Rust written in the most idiomatic way I know

How to use it

First install the app:

cargo intsall khat

See help

If you want to get help for the subcommands:

khat -h

You will receive this output:

Usage: khat.exe [OPTIONS] <FILE>

Arguments:
  <FILE>  The file to the path

Options:
  -f, --full-rev   Displays the file content reversing it entirely
  -l, --line-rev   Displays the file content reversing only the lines
  -c, --chars-rev  Displays the file content reversing only the characters within the lines
  -h, --help       Print help

Normal use

The normal way to use this will be to print the file as is:

khat Cargo.toml

Output:

[package]
name = "khat"
version = "0.1.0"
edition = "2021"
license = "MIT"
description = "A cat clone, nothing more nothing less"
authors = ["kinire98"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = { version = "4.4.10", features = ["derive"]}

Reversing lines

You can also reverse the lines of the document:

khat -l Cargo.toml

Output:

clap = { version = "4.4.10", features = ["derive"]}
[dependencies]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

authors = ["kinire98"]
description = "A cat clone, nothing more nothing less"
license = "MIT"
edition = "2021"
version = "0.1.0"
name = "khat"
[package]

Reversing characters

Another option is reversing the characters within the line

khat -c Cargo.toml

Output:

]egakcap[
"tahk" = eman
"0.1.0" = noisrev
"1202" = noitide
"TIM" = esnecil
"ssel gnihton erom gnihton ,enolc tac A" = noitpircsed
]"89erinik"[ = srohtua

lmth.tsefinam/ecnerefer/ograc/gro.gnal-tsur.cod//:sptth ta snoitinifed rieht dna syek erom eeS #

]seicnedneped[
}]"evired"[ = serutaef ,"01.4.4" = noisrev { = palc

Full reverse

As a final option you can combine both:

khat -r Cargo.toml

Output:

}]"evired"[ = serutaef ,"01.4.4" = noisrev { = palc
]seicnedneped[

lmth.tsefinam/ecnerefer/ograc/gro.gnal-tsur.cod//:sptth ta snoitinifed rieht dna syek erom eeS #

]"89erinik"[ = srohtua
"ssel gnihton erom gnihton ,enolc tac A" = noitpircsed
"TIM" = esnecil
"1202" = noitide
"0.1.0" = noisrev
"tahk" = eman
]egakcap[

Dependencies

~1–11MB
~75K SLoC