#utility #tool #file-line #text

app slice-command

slice is a command-line tool that allows you to slice the contents of a file using syntax similar to Python's slice notation

9 unstable releases (4 breaking)

0.4.1 Mar 27, 2024
0.4.0 Oct 16, 2023
0.3.1 Aug 22, 2023
0.3.0 Jun 26, 2023
0.0.0 Apr 20, 2023

#112 in Text processing

Download history 3/week @ 2024-02-23 1/week @ 2024-03-01 28/week @ 2024-03-08 138/week @ 2024-03-15 134/week @ 2024-03-22 26/week @ 2024-03-29 2/week @ 2024-04-05

305 downloads per month

Apache-2.0 OR MIT

31KB
829 lines

Slice

Slice is a command-line tool written in Rust that allows you to slice the contents of a file using syntax similar to Python's slice notation.

test_workflow Crates.io

Installation

Via Homebrew

brew install chantsune/tap/slice

Via Nix

nix-env --install -f https://github.com/chantsune/slice/tarball/main

Via Cargo

cargo install slice-command

From Source (via Cargo)

git clone https://github.com/ChanTsune/slice.git
cd slice
cargo install --path .

After building, add the binary to your PATH to use it globally.

Usage

To use slice, run the following command:

slice [options] <slice> <file...>

<file> is the name of the file you want to slice, and <slice> is the slice syntax you want to apply to the file. If <file> is not specified, slice will read from standard input.

The slice syntax is similar to Python's slice syntax, with the format start:end:step. Each value is optional and, if omitted, defaults to the beginning of the file, the end of the file, and a step of 1, respectively.

Examples

Here are some examples of how to use slice:

slice 10:20 file.txt

This command slices the contents of file.txt from line 10 to line 20.

slice :100:2 file.txt

This command slices the contents of file.txt from the beginning of the file to line 100, skipping every second line.

slice 5:+10 file.txt

This command is the same as slice 5:15 file.txt`.

For more details, run:

slice --help

Docker

docker build -t slice .
docker run -v `pwd`:`pwd` -w `pwd` --rm -i slice

License

Dual-licensed under MIT or Apache-2.0.

Dependencies

~1.3–1.8MB
~35K SLoC