Skip to content

guillaumeast/strui-cpp-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

πŸ› οΈ strui (C++ cli) v1.0.0

Tiny Unicode‑aware & ANSI‑aware string C++ CLI – built on top of strui-cpp-lib.

C++ Type: CLI Platform: Unix Status: v1.0.0

strui is the command‑line face of strui-cpp-lib:
think of it as a minimal, UTF‑8‑smart replacement for cut, wc, or tr that understands emojis and ANSI escapes.


✨ Features

  • Everything from strui-cpp-lib available at the tips of your fingers:
    • clean ANSI escapes
    • measure visual width / height
    • split / join / repeat helpers
    • substring count
  • UTF‑8 aware (CJK, wide & combined emojis)
  • Zero runtime dependencies – the binary is fully self-contained
  • Ships as one small binary (<50β€―KB)

πŸš€ Quick install

git clone https://github.com/guillaumeast/strui-cpp-cli.git
cd strui-cpp-cli
make install

πŸ™ˆ If you're on Windows:
Don’t worry β€” we all make mistakes.
Fire up wsl, and pretend it never happened.

✨ Join us on the bright (terminal) side.


πŸ“¦ Dependencies

  • Runtime: None
  • Build-time:
    • libunistring β‰₯ 1.1 (statically linked)
    • Any C++17 compiler (g++, clang++, …)

πŸ–₯️ Usage

Command Description
strui width <string> Return visual width (columns) of string
strui height <string> Return number of lines in string
strui clean <string> Remove ANSI escape sequences
strui split <string> <separator> Vector‑split string on separator
strui join ?--separator ?<separator> <...strings...> Join strings with optional separator
strui repeat <count> <string> ?<separator> Repeat string count times
strui count <value> <string> Count occurrences of value in string

Display width is measured in columns, of characters or strings, when output to a device that uses non-proportional fonts.
Note that for some rarely used characters the actual fonts or terminal emulators can use a different width. There is no mechanism for communicating the display width of characters across a Unix pseudo-terminal (tty).
Also, there are scripts with complex rendering, like the Indic scripts. For these scripts, there is no such concept as non-proportional fonts. Therefore the results of these functions usually work fine on most scripts and on most characters but can fail to represent the actual display width.
πŸ“š See libunistring documentation – Display width <uniwidth.h> for details on how display width is computed.


πŸ§ͺ Tests

Requirement: Docker

Tests are run locally and inside an Ubuntu container to guarantee portability.

make test          # build + tests

πŸ“ Project structure

strui/
β”œβ”€β”€ Makefile
β”œβ”€β”€ include/strui.hpp   # strui-cpp-lib header
β”œβ”€β”€ src/main.cpp        # CLI implementation
β”œβ”€β”€ build/              # autogenerated binary (can be .gitignored)
└── tests/
    β”œβ”€β”€ volume/         # auto-generated at runtime by `run.sh` (can be .gitignored)
    β”œβ”€β”€ run.sh          # test orchestrator (POSIX sh)
    β”œβ”€β”€ test.sh         # unit tests (POSIX sh)
    └── Dockerfile      # ubuntu image description for portability tests

β€œMeasure what you see β€” not what you store.” πŸ“

About

Minimal string CLI in C++ β†’ Clean, measure & reshape terminal text (Unicode/ANSI-aware).

Topics

Resources

License

Stars

Watchers

Forks