https://github.com/shresht7/tali
Count the number of lines, words, characters and bytes in a given set of files
https://github.com/shresht7/tali
Last synced: 8 months ago
JSON representation
Count the number of lines, words, characters and bytes in a given set of files
- Host: GitHub
- URL: https://github.com/shresht7/tali
- Owner: Shresht7
- License: mit
- Created: 2025-02-15T12:16:35.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-19T21:20:24.000Z (about 1 year ago)
- Last Synced: 2025-03-19T21:37:05.220Z (about 1 year ago)
- Language: Rust
- Homepage:
- Size: 134 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `tali`
A command-line application to count the number of lines, words, characters and bytes in a given set of files.

## 🌟 Features
- **Scanning**: Scan a set of files (or directories) for the number of lines, words, characters and bytes.
- **Language Detection**: Determines the languages used (based on the file extension)
- **Configurable Output**: Choose from multiple output formats (Table, CSV, TSV, JSON)
- **Colorized**: Defaults to a colorized output when printing to the console.
- **Visualization**: Displays a graphical measure of each file's size relative to the largest file.
- **Group by Language**: Aggregate and group the results by language
---
## 📦 Installation
## 📘 Usage
Run `tali` by specifying one or more files or directories to scan:
```sh
tali path/to/directory
```
By default, `tali` outputs the results in a tabular format with colors.

The output can be configured using the various command-line arguments.
### Options
- `-l, --lines`: Shows the line count
- `-w, --words`: Show the word count
- `-c, --chars`: Shows the character count
- `-b, --bytes`: Show the byte count
- `-e, --language`: Show the corresponding language
- `-v, --graph`: Show a graphical visualization
- `-f, --format`: Configures the output format (`"table"`, `"json"`, `"plain"`)
- `--sort-by [metric]`: Sorts the output by the specified metric (`lines`, `words`, `chars` or `bytes`)
- `--sort-order [order]`: Sorts in `ascending` or `descending` order
- `--graph-by [metric]`: Uses the specified metric for the graphical visualization (`lines`, `words`, `chars`, or `bytes`)
Use `--help` to get the full help for more details.
### Examples
#### Scan the current directory
```sh
tali
```
#### Scan a specific directory
```sh
tali src
```
#### Count lines in a file
```sh
tali README.md --lines
```
#### Scan a directory and group results by languages
```sh
tali projects --group
```
#### Show language, lines, and characters in JSON format
```sh
tali src --language --lines --chars --format json
```
#### Scan multiple files and output as plain text
```sh
tali README.md .gitignore src --lines --format plain
```
#### Exclude specific files
```sh
tali src --exclude "*.md,*.toml"
```
---
## ⚽ Goals
- Learn Rust
- Build Stuff
## 🖥️ Development
### Project Structure
The cli logic resides in [`main.rs`](./src/main.rs) and the definitions for the command-line arguments are in the [`cli.rs`](./src/cli.rs) file.
The library [`src/lib`](./src/lib/) contains three modules:
- [`scanner`](./src/lib/scanner/): Responsible for walking the file-system and scanning the file metrics
- [`output`](./src/lib/output/): Responsible for formatting and displaying the scan results.
- [`helpers`](./src/lib/helpers/): An amalgamation of helpers and utilities used throughout the project.
### 📕 References
- https://github.com/XAMPPRocky/tokei
- https://boyter.org/posts/sloc-cloc-code/
- https://github.com/cgag/loc
- https://github.com/boyter/scc
---
## 📄 License
This project is licensed under the [MIT LICENSE](./LICENSE). See the [LICENSE](./LICENSE) file for more details.