@@ -8,15 +8,40 @@ A minimalist BusyBox alternative written in modern C++23.
88[ ![ License: MIT] ( https://img.shields.io/badge/License-MIT-yellow.svg )] ( https://opensource.org/licenses/MIT )
99[ ![ C++23] ( https://img.shields.io/badge/C++23-00599C?logo=cplusplus )] ( https://en.cppreference.com/w/cpp/23 )
1010[ ![ CMake] ( https://img.shields.io/badge/CMake-3.26+-064F8C?logo=cmake )] ( https://cmake.org/ )
11- [ ![ Tests] ( https://img.shields.io/badge/Tests-149_passing -brightgreen )] ( tests/ )
12- [ ![ Applets] ( https://img.shields.io/badge/Applets-17 -brightgreen )] ( src/applets/ )
11+ [ ![ Tests] ( https://img.shields.io/badge/Tests-331_passing -brightgreen )] ( tests/ )
12+ [ ![ Applets] ( https://img.shields.io/badge/Applets-109 -brightgreen )] ( src/applets/ )
1313
1414## Overview
1515
16- CFBox is a single-executable Unix utility collection distributed via symbolic links. 17 applets implemented and tested, with a CI pipeline covering native builds, cross-compilation, and QEMU user/system-mode testing across 5 stages . Features configurable CMake builds (per-applet toggles), GNU-style long options, and colored help output.
16+ CFBox is a single-executable Unix utility collection distributed via symbolic links. 109 applets implemented and tested, with a CI pipeline covering native builds, cross-compilation, and QEMU user/system-mode testing. Features configurable CMake builds (per-applet toggles), GNU-style long options, and colored help output.
1717
1818** Design philosophy:** Simplicity first — Modern C++ (` std::expected ` ) — Embedded-friendly (cross-compilation, static linking)
1919
20+ ## Size Comparison
21+
22+ | Project | Language | Size | Applets | Size/Applet |
23+ | ---------| ----------| ------| ---------| -------------|
24+ | ** CFBox (size-opt)** | ** C++23** | ** 446 KB** | ** 109** | ** ~ 4.1 KB** |
25+ | Toybox | C | ~ 500 KB | 238 | ~ 2.1 KB |
26+ | BusyBox (full) | C | ~ 1.7 MB | 274 | ~ 9 KB |
27+ | uutils/coreutils | Rust | ~ 11 MB | ~ 100 | ~ 110 KB |
28+
29+ > CFBox is ** 3-4x smaller** than BusyBox while providing a complete AWK interpreter, archive suite (tar/cpio/ar/unzip/gzip), diff/patch (Myers O(ND) algorithm), process tools (ps/top/pstree/pgrep/pmap), and a built-in TUI framework.
30+
31+ ## Performance
32+
33+ | Operation | Data Size | Time |
34+ | -----------| -----------| ------|
35+ | grep -c | 10 MB | 54 ms |
36+ | cat | 10 MB | 63 ms |
37+ | wc | 10 MB | 17 ms |
38+ | sort | 100K lines | 32 ms |
39+ | diff | 100K lines (similar) | 79 ms |
40+
41+ - grep/cat/wc use streaming I/O — reading ` /dev/urandom ` won't exhaust memory
42+ - diff uses Myers O(ND) algorithm; sort precomputes keys to avoid repeated allocation
43+ - Zero external dependencies: hand-written lightweight deflate/inflate replaces zlib
44+
2045## Quick Start
2146
2247``` bash
@@ -25,8 +50,8 @@ cmake -B build
2550cmake --build build
2651
2752# Test
28- ctest --test-dir build --output-on-failure # 149 GTest unit tests
29- bash tests/integration/run_all.sh # 17 integration test scripts
53+ ctest --test-dir build --output-on-failure # 331 GTest unit tests
54+ bash tests/integration/run_all.sh # 54 integration test scripts
3055
3156# Run via subcommand
3257./build/cfbox echo " Hello, World!"
@@ -36,44 +61,37 @@ bash tests/integration/run_all.sh # 17 integration test scripts
3661echo " Hello, World!" # now calls cfbox via symlink
3762```
3863
39- ## Supported Commands
64+ ## Supported Commands (109)
65+
66+ ### Text Processing (28)
67+
68+ ` echo ` , ` printf ` , ` cat ` , ` head ` , ` tail ` , ` wc ` , ` sort ` , ` uniq ` , ` grep ` , ` sed ` , ` fold ` , ` expand ` , ` cut ` , ` paste ` , ` nl ` , ` comm ` , ` tr ` , ` tac ` , ` rev ` , ` shuf ` , ` factor ` , ` od ` , ` split ` , ` seq ` , ` tsort ` , ` expr ` , ` awk ` , ` diff ` + ` patch ` + ` cmp ` + ` ed `
69+
70+ ### File Operations (20)
71+
72+ ` mkdir ` , ` rm ` , ` cp ` , ` mv ` , ` ls ` , ` find ` , ` ln ` , ` touch ` , ` stat ` , ` install ` , ` mktemp ` , ` truncate ` , ` du ` , ` df ` , ` readlink ` , ` realpath ` , ` rmdir ` , ` link ` , ` unlink ` , ` chmod `
73+
74+ ### Archive & Compression (6)
75+
76+ ` tar ` (ustar format), ` cpio ` (newc format), ` ar ` (static library), ` unzip ` , ` gzip ` , ` gunzip `
77+
78+ ### Shell & Scripting (2)
4079
41- ### Text Processing
80+ ` sh ` (POSIX shell: pipes, redirections, variable expansion, command substitution, if/while/for, 15 builtins), ` xargs `
4281
43- | Applet | Supported Flags / Features |
44- | --------| ----------------------------|
45- | ` echo ` | ` -n ` (no trailing newline), ` -e ` (interpret escape sequences), all applets support ` --help ` / ` --version ` |
46- | ` printf ` | Format strings (` %s ` ` %d ` ` %f ` ` %c ` ` %% ` ), format reuse |
47- | ` cat ` | ` -n ` (number lines), ` -b ` (number non-blank), ` -A ` (show non-printing), stdin passthrough |
48- | ` head ` | ` -n N ` (first N lines), ` -c N ` (first N bytes), multi-file headers |
49- | ` tail ` | ` -n N ` (last N lines), ` -c N ` (last N bytes), multi-file footers |
50- | ` wc ` | ` -l ` (lines), ` -w ` (words), ` -c ` (bytes), ` -m ` (chars), multi-file totals |
51- | ` sort ` | ` -r ` (reverse), ` -n ` (numeric), ` -u ` (unique), ` -k N ` (key field), multi-file merge |
52- | ` uniq ` | ` -c ` (count), ` -d ` (duplicates only), ` -u ` (unique only), stdin support |
53- | ` grep ` | ` -E ` (extended regex), ` -i ` (ignore case), ` -v ` (invert), ` -n ` (line numbers), ` -r ` (recursive), ` -c ` (count), ` -l ` (files with matches), ` -q ` (quiet) |
54- | ` sed ` | ` -n ` (suppress auto-print), ` -e SCRIPT ` ; substitution ` s/pat/repl/[g\|p\|d] ` , line addresses, ranges, ` $ ` |
82+ ### System Info (20)
5583
56- ### File Operations
84+ ` pwd ` , ` basename ` , ` dirname ` , ` uname ` , ` hostname ` , ` whoami ` , ` id ` , ` tty ` , ` date ` , ` nproc ` , ` logname ` , ` hostid ` , ` printenv ` , ` env ` , ` uptime ` , ` free ` , ` cal ` , ` dmesg ` , ` who ` , ` test `
5785
58- | Applet | Supported Flags / Features |
59- | --------| ----------------------------|
60- | ` mkdir ` | ` -p ` /` --parents ` (create parents), ` -m ` /` --mode MODE ` (permissions) |
61- | ` rm ` | ` -r ` /` --recursive ` (recursive), ` -f ` /` --force ` (force), ` -i ` (interactive), ` / ` safety check |
62- | ` cp ` | ` -r ` /` --recursive ` (recursive), ` -p ` /` --preserve ` (preserve permissions), multi-file to directory |
63- | ` mv ` | ` -f ` (force overwrite), cross-filesystem fallback (copy + remove) |
86+ ### Process Management (15)
6487
65- ### Directory & Search
88+ ` ps ` , ` top ` , ` kill ` , ` pgrep ` / ` pkill ` , ` pidof ` , ` pstree ` , ` pmap ` , ` fuser ` , ` pwdx ` , ` sysctl ` , ` iostat ` , ` watch ` , ` nice ` , ` renice ` , ` timeout `
6689
67- | Applet | Supported Flags / Features |
68- | --------| ----------------------------|
69- | ` ls ` | ` -a ` /` --all ` (show hidden), ` -l ` /` --long ` (long format), ` -h ` /` --human-readable ` (human-readable sizes) |
70- | ` find ` | ` -name PATTERN ` (glob), ` -type [f\|d\|l] ` , ` -maxdepth N ` , ` -exec CMD {} ; ` |
90+ ### Other (18)
7191
72- ### System
92+ ` true ` , ` false ` , ` yes ` , ` sleep ` , ` usleep ` , ` sync ` , ` nohup ` , ` cksum ` , ` md5sum ` , ` sum ` , ` hexdump ` , ` more ` , ` tee ` , ` init ` (PID 1 initramfs init system), ` mkfifo ` , ` mknod ` , ` sleep ` , ` sh `
7393
74- | Applet | Description |
75- | --------| -------------|
76- | ` init ` | System initialization — auto-mounts proc/sysfs/devtmpfs when PID 1, runs smoke tests, then powers off |
94+ > All applets support ` --help ` / ` --version `
7795
7896## Requirements
7997
@@ -86,9 +104,10 @@ echo "Hello, World!" # now calls cfbox via symlink
86104| Document | Description |
87105| ----------| -------------|
88106| [ Architecture & Design] ( document/architecture.md ) | Dispatch mechanism, core infrastructure, error handling, testing |
107+ | [ Roadmap] ( Roadmap.md ) | 7-phase development plan, current progress, architecture decisions |
89108| [ Cross-Compilation & Embedded] ( document/cross-compilation.md ) | Toolchains, CMake options, build examples, binary sizes |
90109| [ QEMU Testing] ( document/qemu-testing.md ) | User-mode / system-mode testing, init applet, kernel config |
91- | [ Continuous Integration] ( document/ci.md ) | CI pipeline 5-stage overview |
110+ | [ Continuous Integration] ( document/ci.md ) | CI pipeline overview |
92111| [ Contributing Guide] ( CONTRIBUTING.md ) | Build, test, code style, submission |
93112
94113## Project Structure
@@ -99,28 +118,30 @@ cfbox/
99118├── cmake/
100119│ ├── Config.cmake # Per-applet configuration (CFBOX_ENABLE_xxx options)
101120│ ├── compile/CompilerFlag.cmake # Compiler warnings & optimization flags
102- │ ├── third_party/CPM.cmake # CPM dependency manager
121+ │ ├── third_party/CPM.cmake # CPM dependency manager (GTest only)
103122│ └── toolchain/ # Cross-compilation toolchains
104- ├── configs/
105- │ └── qemu-virt-aarch64.config # Minimal QEMU aarch64 kernel config
106- ├── document/ # Detailed documentation
107123├── include/cfbox/
108- │ ├── applet_config.hpp.in # CMake-generated config (version + enable flags)
109124│ ├── applet.hpp / applets.hpp # Registry & dispatch
110125│ ├── args.hpp # Short + long option argument parser
111- │ ├── help.hpp # --help / --version help system
126+ │ ├── error.hpp # std::expected error handling + CFBOX_TRY
127+ │ ├── io.hpp # Streaming I/O (for_each_line, read_all, write_all)
128+ │ ├── stream.hpp # Line-by-line pipeline, LineProcessor
129+ │ ├── deflate.hpp / inflate.hpp # Hand-written lightweight DEFLATE (zero deps)
130+ │ ├── compress.hpp # gzip wrapper
131+ │ ├── utf8.hpp # Unicode width/count (constexpr + static_assert)
112132│ ├── term.hpp # ANSI colored output (NO_COLOR support)
113- │ ├── utf8.hpp # Unicode-aware width/count utilities
114- │ └── ... # error.hpp, io.hpp, fs_util.hpp, escape.hpp
133+ │ ├── terminal.hpp # Terminal control (RawMode RAII, cursor, double buffer)
134+ │ ├── tui.hpp # TUI framework (ScreenBuffer, Key, TuiApp)
135+ │ ├── proc.hpp # /proc parser (processes, memory, CPU, disks)
136+ │ ├── regex.hpp # POSIX regex RAII (scoped_regex)
137+ │ └── ... # help.hpp, fs_util.hpp, escape.hpp, checksum.hpp
115138├── src/
116139│ ├── main.cpp # Dispatch entry
117- │ └── applets/ # 17 command implementations
140+ │ └── applets/ # 109 command implementations
118141├── tests/
119- │ ├── unit/ # GTest unit tests (149 cases)
120- │ └── integration/ # Shell integration tests (17 scripts)
121- ├── scripts/ # Build, test, install scripts
122- ├── .github/workflows/ci.yml # CI pipeline
123- └── CONTRIBUTING.md # Contributing guide
142+ │ ├── unit/ # GTest unit tests (331 cases)
143+ │ └── integration/ # Shell integration tests (54 scripts)
144+ └── scripts/ # Build, test, install scripts
124145```
125146
126147## Contributing
0 commit comments