@@ -76,6 +76,100 @@ camelCase("hello-world"); // 'helloWorld'
7676truncate (" Long text here" , 10 ); // 'Long te...'
7777```
7878
79+ ## CLI
80+
81+ Nano String Utils includes a command-line interface for quick string transformations directly in your terminal.
82+
83+ ### Installation
84+
85+ When installed globally or used with ` npx ` , the CLI is available as ` nano-string ` :
86+
87+ ``` bash
88+ # Global installation
89+ npm install -g nano-string-utils
90+ nano-string slugify " Hello World"
91+
92+ # Using npx (no installation required)
93+ npx nano-string-utils slugify " Hello World"
94+ ```
95+
96+ ### Basic Usage
97+
98+ ``` bash
99+ nano-string < function> < input> [options]
100+ ```
101+
102+ ### Examples
103+
104+ #### Simple transformations
105+ ``` bash
106+ nano-string slugify " Hello World!" # hello-world
107+ nano-string camelCase " hello-world" # helloWorld
108+ nano-string kebabCase " hello_world" # hello-world
109+ nano-string capitalize " hello" # Hello
110+ nano-string reverse " hello" # olleh
111+ ```
112+
113+ #### Using pipes
114+ ``` bash
115+ echo " Hello World" | nano-string slugify # hello-world
116+ cat file.txt | nano-string truncate --length 50
117+ ```
118+
119+ #### Functions with options
120+ ``` bash
121+ # Truncate with custom length
122+ nano-string truncate " Long text here" --length 10 # Long te...
123+
124+ # Template interpolation
125+ nano-string template " Hello {{name}}" --data ' {"name":"World"}' # Hello World
126+
127+ # Pad strings
128+ nano-string padStart " hi" --length 5 --char " *" # ***hi
129+
130+ # Generate random strings
131+ nano-string randomString --length 10 # Generates 10-character string
132+ ```
133+
134+ #### Validation functions
135+ ``` bash
136+ nano-string isEmail
" [email protected] " # true137+ nano-string isUrl " https://example.com" # true
138+ nano-string isASCII " hello" # true
139+ ```
140+
141+ #### Analysis functions
142+ ``` bash
143+ nano-string wordCount " hello world test" # 3
144+ nano-string levenshtein " kitten" " sitting" # 3
145+ nano-string diff " hello" " hallo" # Shows differences
146+ ```
147+
148+ ### Available Commands
149+
150+ To see all available functions:
151+ ``` bash
152+ nano-string --help
153+ ```
154+
155+ For help on a specific function:
156+ ``` bash
157+ nano-string slugify --help
158+ ```
159+
160+ ### Supported Functions
161+
162+ The CLI supports most functions from the library:
163+ - ** Case Conversions** : slugify, camelCase, snakeCase, kebabCase, pascalCase, constantCase, dotCase, pathCase, sentenceCase, titleCase
164+ - ** String Manipulation** : capitalize, reverse, truncate, excerpt, pad, padStart, padEnd
165+ - ** Text Processing** : stripHtml, escapeHtml, deburr, normalizeWhitespace, removeNonPrintable, toASCII
166+ - ** Validation** : isEmail, isUrl, isASCII
167+ - ** Analysis** : wordCount, levenshtein, levenshteinNormalized, diff
168+ - ** Generation** : randomString, hashString
169+ - ** Unicode** : graphemes, codePoints
170+ - ** Pluralization** : pluralize, singularize
171+ - ** Templates** : template, templateSafe, highlight, fuzzyMatch
172+
79173## API Reference
80174
81175### String Transformation
0 commit comments