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

app line_grub

A command line tool deal with unfortunately long one-string files

3 releases

0.1.2 Sep 29, 2022
0.1.1 Sep 29, 2022
0.1.0 Sep 29, 2022

#2233 in Command line utilities

50 downloads per month

MIT/Apache

8KB

line_grub

line_grub is a teeny command line tool that was created to ease the pain of dealing with unfortunately long strings. Wherever they are.

Ones like these:

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.

Oof...

An Explanation

It's super simple. Install it to your path, enter the command below and...

line_grub long_string_file.txt output.txt

You get this:

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. 

A little bit better right?

If you want to add a 4 space tab at any location in your string just add "\" at any point in the string. For example:

\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.

And you get this!:

    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.

Most text editors do have great word-wrapping. So in many cases, you'll be fine without this tbh. But for those times when you're purely on the command line, it can come in handy! It's also helpful for debugging.

Using line_grub

line_grub is available on crates.io. The way to use it is as of now is to get it through Cargo. I will add excutables very soon.

cargo install line_grub

line_grub currently requires rustc 1.46.0 or greater.

Contribution

line_grub is an open source project that is extremely new! Note that all code submitted in PRs to line_grub is assumed to be licensed under line_grub's dual MIT/Apache2 licensing.

License

line_grub is distributed under the terms of both the MIT license and the Apache License (Version 2.0). See LICENSE-APACHE and LICENSE-MIT for details. Opening a pull request is assumed to signal agreement with these licensing terms.

Dependencies

~1.3–2MB
~37K SLoC