Skip to content
Project template·Pro

Rust CLI: line counter

A command-line tool in Rust that counts code, comment and blank lines per language in a folder. It's a Cargo project with no dependencies and has unit tests. It needs Rust and Cargo in the Linux environment (about 370 MB).

You need PocketCode Pro to install it.

If PocketCode is installed on your Android device, this opens the page in the app.

Preview

Files

Cargo.lock
Cargo.toml
README.md
src/count.rs
src/main.rs

README.md

# loc: a Rust command-line tool Counts lines of code, comments and blank lines per language in a folder, like a small `cloc`. It skips `.git`, `target`, `node_modules` and other build or dependency folders. A Cargo project with no dependencies (only the standard library), split into two modules, with unit tests. ## Run it in PocketCode You need the app's Linux environment with Rust and Cargo (install it in Settings › Compilers and runtimes; about 370 MB). 1. Open the terminal in this project's folder (Open Terminal Here, in the editor menu). 2. Build and run it on this project: ```sh cargo run -- . ``` The first build takes a while on a phone; later ones only rebuild what changed. 3. Point it at any folder of your projects, and sort the table: ```sh cargo run -- ../other-project --sort files cargo run -- --help ``` You can also open `src/main.rs` and tap Run: it counts the `src` folder. ## Run the tests ```sh cargo test ``` ## Build a release binary ```sh cargo build --release ./target/release/loc ~/some/folder ``` ## Where things are

This preview is shortened. You get the full content when you install it.

Changes in 1.0.0

First version.

Related

Python CLI with SQLiteProProject templateAn expense tracker for the terminal. It adds and lists expenses, totals them per category each month and exports CSV. It only uses the standard library (argparse, sqlite3), so there's nothing to pip install, and it has unittest tests. It needs Python in the Linux environment.Node.js JSON API without dependenciesProProject templateA notes API on node:http: create, list, update and delete notes, with input checks and JSON errors, saved to a file. You don't install anything. Tap Run on server.js and the app's own Node.js starts it on localhost:3000. The project includes tests.Next.js + Tailwind + i18nProProject templateNext.js 15 project with next-intl and Tailwind CSS, and one page in English and Spanish at /en and /es. Dark mode follows the system. Needs the Linux environment with Node.js; the first npm install downloads around 400 MB.Rust snippetsFreeSnippets20 Rust snippets that only use the standard library, except one serde struct: error enums with From, iterator chains, counting with HashMap, let else, threads with Arc and Mutex, channels and a test module.Static landing pageProProject templateA one-page site in plain HTML and CSS with a header and folding menu, a hero, a feature grid, an FAQ and a footer. Colours follow the system's light or dark setting. There is no build step and it doesn't need Linux: open index.html and tap the globe icon.Flask + SQLite web appProProject templateA reading list in Flask with server-rendered pages and plain forms, SQLite storage and a small JSON API. The tests use Flask's test client. It needs Python and pip in the Linux environment and installs 7 pinned packages.