|
1 | 1 | # Random Generator CLI |
2 | 2 |
|
3 | | -<p> |
4 | | - <!-- NPM version badge --> |
5 | | - <a href="https://www.npmjs.com/package/random-generator-cli"> |
6 | | - <img src="https://img.shields.io/npm/v/random-generator-cli" alt="version"/> |
7 | | - </a> |
8 | | - |
9 | | - <!-- Github "Test Main" workflow status --> |
10 | | - <a href="https://github.com/AmrSaber/random-cli/actions"> |
11 | | - <img src="https://github.com/AmrSaber/random-cli/workflows/Test%20Master/badge.svg" alt="Test Master Status"/> |
12 | | - </a> |
13 | | - |
14 | | - <!-- Github "Test Dev" workflow status --> |
15 | | - <a href="https://github.com/AmrSaber/random-cli/actions"> |
16 | | - <img src="https://github.com/AmrSaber/random-cli/workflows/Test%20Dev/badge.svg" alt="Test Dev Status"/> |
17 | | - </a> |
18 | | - |
19 | | - <!-- NPM weekly downloads --> |
20 | | - <a href="https://www.npmjs.com/package/random-generator-cli"> |
21 | | - <img src="https://img.shields.io/npm/dw/random-generator-cli" alt="weekly downloads"/> |
22 | | - </a> |
23 | | - |
24 | | - <!-- License --> |
25 | | - <a href="https://github.com/AmrSaber/random-cli/blob/master/LICENSE"> |
26 | | - <img src="https://img.shields.io/npm/l/random-generator-cli" alt="license"/> |
27 | | - </a> |
28 | | -</p> |
| 3 | +> Old package published on npm has been removed since it was broken and I don't intend to fix it. |
29 | 4 |
|
30 | 5 | Generates and prints a secure random string (and other types) to terminal. |
31 | 6 |
|
32 | | -> We use a cryptographically secure pseudo random number generator (CSPRNG, using `crypto`) for all the randomization and not `Math.random`. |
33 | | -
|
34 | | -## Install |
35 | | -Install the package globally to be able to use it in the terminal. |
36 | | - |
37 | | -```bash |
38 | | -npm i -g random-generator-cli |
39 | | -``` |
40 | | - |
41 | | -## Examples |
42 | | -``` |
43 | | -$ random string |
44 | | -LQQF5iTLVEawRGKqs4BN |
45 | | -
|
46 | | -$ random array |
47 | | -3 7 10 1 2 4 6 8 5 9 |
48 | | -
|
49 | | -$ random number 1 10 |
50 | | -9 |
51 | | -
|
52 | | -$ random float |
53 | | -0.24374674185057454423031231272034347057342529296875 |
54 | | -
|
55 | | -$ random boolean |
56 | | -true |
57 | | -
|
58 | | -$ random pick a b c d e |
59 | | -d |
60 | | -
|
61 | | -$ random shuffle a b c d e |
62 | | -b d a e c |
63 | | -``` |
64 | | - |
65 | 7 | ## Usage |
66 | 8 | After installation, use `random <command>`, you can use `random <command> -h` to show help message related to that command, or use `random -h` to list all the available commands and options. |
67 | 9 |
|
68 | 10 | ### Commands |
69 | | -Available commands are [`string`, `array`, `number`, `float`, `boolean`, `pick`, `shuffle`], each of theses commands will be explained next. |
70 | | - |
71 | | -#### `string` |
72 | | -Prints a random string with given length and type, also has the alias `str`. |
73 | | - |
74 | | -String options: |
75 | | -| Option | Alias | Type | Default | Description | |
76 | | -|---------|-------|--------|-----------|---------------------------------| |
77 | | -| length | l | Number | `20` | String length | |
78 | | -| type | t | Number | `ascii` | String type (see table below) | |
79 | | - |
80 | | -And the supported types are: |
81 | | -| Type | Description | Example | |
82 | | -|-----------------|------------------------------------------------------|----------------------| |
83 | | -| ascii (default) | Uppercase letters, lowercase letters, and numbers | 8AlB9IUu7ptWqkp3tbeQ | |
84 | | -| letters | Uppercase letters and lowercase letters | pPOzEvraFpVFJgCXPdXR | |
85 | | -| numbers | Numbers (each character from 0 to 9) | 71110932458602457566 | |
86 | | -| extended | Same as ascii plus the characters `+-_$#/@!` | fX#InRyripY@+f!Q7o7R | |
87 | | -| base64 | Base 64 string | XU0tg2OW43GJCh5IrrX= | |
88 | | -| hex | Hex number (with uppercase and lowercase characters) | 7bCCB51BEb9bDd61f6af | |
89 | | - |
90 | | -Examples |
91 | | -``` |
92 | | -$ random string -c 2 |
93 | | -vDboPtnabvsuEztusNAl |
94 | | -YMasHVICXbbQxCLVMMuF |
95 | | -
|
96 | | -$ random string -l 15 -c 3 -t numbers |
97 | | -366208018712690 |
98 | | -991841686515201 |
99 | | -575580372097167 |
100 | | -
|
101 | | -$ random str -t extendedarray 15 --pad |
102 | | -14 11 12 15 13 03 08 07 05 06 02 01 09 04 10 |
103 | | -zrk+MQP$_j5pWUWxBV!m |
104 | | -``` |
105 | | - |
106 | | -#### `array [length]` |
107 | | -Prints a shuffled array that starts at 1 by default, also accepts optional length argument that defaults to 10, and has the alias `arr`. |
108 | | - |
109 | | -Note: the flag `-0` can be used to indicate that the array should start at 0. |
110 | | - |
111 | | -Array options: |
112 | | -| Option | Alias | Type | Default | Description | |
113 | | -|-----------|-------|--------|-----------|--------------------------------------------------------------| |
114 | | -| start | s | Number | `1` | Array starting position, overrides `-0` if both are provided | |
115 | | -| end | e | Number | - | Array ending, overrides `length` | |
116 | | -| delimiter | d | String | `' '` | The delimiter that is printed between array numbers | |
117 | | - |
118 | | -Array flags: |
119 | | -| Flag | Alias | Default | Description | |
120 | | -|-------------|-------|-----------|----------------------------------------------------------------------| |
121 | | -| startAtZero | 0 | `false` | Array elements start at 0, equivalent to `-s 0` | |
122 | | -| pad | - | `false` | Add zero-padding to small number, so all number have the same length | |
123 | | - |
124 | | -Examples: |
125 | | -``` |
126 | | -$ random array |
127 | | -3 9 2 6 4 1 10 7 8 5 |
128 | | -
|
129 | | -$ random array 5 |
130 | | -4 1 5 3 2 |
131 | | -
|
132 | | -$ random array 5 -0 |
133 | | -2 0 4 1 3 |
134 | | -
|
135 | | -$ random arr 5 -s 5 |
136 | | -5 6 8 9 7 |
137 | | -
|
138 | | -$ random arr -s 5 -e 10 |
139 | | -5 9 6 10 7 8 |
140 | | -
|
141 | | -$ random arr 5 -d ', ' |
142 | | -4, 2, 5, 3, 1 |
143 | | -
|
144 | | -$ random array 15 --pad |
145 | | -14 11 12 15 13 03 08 07 05 06 02 01 09 04 10 |
146 | | -
|
147 | | -$ random array 5 --pad |
148 | | -1 2 5 4 3 |
149 | | -``` |
150 | | - |
151 | | -#### `number <min> <max>` |
152 | | -Prints a random number between `min` and `max`, also has the aliases: [`num`, `integer`, `int`]. |
153 | | - |
154 | | -Example |
155 | | -``` |
156 | | -$ random number 1 20 |
157 | | -17 |
158 | | -
|
159 | | -$ random num 0 5 |
160 | | -3 |
161 | | -
|
162 | | -$ random int 100 1000 |
163 | | -240 |
164 | | -``` |
165 | | - |
166 | | -#### `float` |
167 | | -Prints a float number between 0 (inclusive) and 1 (exclusive). |
168 | | - |
169 | | -Float options: |
170 | | -| Option | Alias | Type | Default | Description | |
171 | | -|-----------|-------|--------|-----------|----------------------------------------------------| |
172 | | -| precision | p | Number | `10` | The desired precision of the floating point number | |
173 | | - |
174 | | -Example |
175 | | -``` |
176 | | -$ random float |
177 | | -0.24374674185057454423031231272034347057342529296875 |
178 | | -
|
179 | | -$ random float -p 5 |
180 | | -0.62194 |
181 | | -``` |
182 | | - |
183 | | -#### `boolean` |
184 | | -Prints a random boolean, has the alias `bool`. |
185 | | - |
186 | | -Boolean options: |
187 | | -| Option | Alias | Type | Default | Description | |
188 | | -|--------|-------|--------|--------------|---------------------------------------------------| |
189 | | -| type | t | String | `true-false` | Boolean type, types are listed in the table below | |
190 | | - |
191 | | -Boolean types: |
192 | | -| Type | Possible values | Example | |
193 | | -|----------------------|-------------------|---------| |
194 | | -| true-false (default) | [`true`, `false`] | true | |
195 | | -| yes-no | [`yes`, `no`] | no | |
196 | | -| numeric | [`1`, `0`] | 1 | |
197 | | - |
198 | | -Example |
199 | | -``` |
200 | | -$ random boolean |
201 | | -false |
202 | | -
|
203 | | -$ random boolean |
204 | | -true |
205 | | -``` |
206 | | - |
207 | | -#### `pick <items..>` |
208 | | -Prints a random item(s) from the given items |
209 | | - |
210 | | -Boolean options: |
211 | | -| Option | Alias | Type | Default | Description | |
212 | | -|-----------|-------|--------|---------|--------------------------------------------------| |
213 | | -| number | n | Number | `1` | The number of items to chose, without repetition | |
214 | | -| delimiter | d | String | `' '` | Delimiter that separates the chosen items | |
215 | | - |
216 | | -Example |
217 | | -``` |
218 | | -$ random pick a1 a2 a3 a4 |
219 | | -a3 |
220 | | -
|
221 | | -$ random pick a1 a2 a3 a4 -n 2 |
222 | | -a4 a2 |
223 | | -
|
224 | | -$ random pick a1 a2 a3 a4 -n 2 -d ', ' |
225 | | -a2, a3 |
226 | | -``` |
227 | | - |
228 | | -#### `shuffle <items..>` |
229 | | -Shuffles the given array of items |
230 | | - |
231 | | -Boolean options: |
232 | | -| Option | Alias | Type | Default | Description | |
233 | | -|-----------|-------|--------|---------|---------------------------------------------| |
234 | | -| delimiter | d | String | `' '` | Delimiter that separates the shuffled items | |
235 | | - |
236 | | -Example |
237 | | -``` |
238 | | -$ random shuffle a1 a2 a3 a4 |
239 | | -a2 a3 a4 a1 |
240 | | -
|
241 | | -$ random shuffle a1 a2 a3 a4 -d '|' |
242 | | -a1|a4|a3|a2 |
243 | | -``` |
244 | | - |
245 | | -### Global Options |
246 | | - |
247 | | -| Option | Alias | Type | Default | Description | |
248 | | -|---------|-------|--------|---------|-----------------------------| |
249 | | -| help | h | - | - | Show help message | |
250 | | -| version | v | - | - | Show package version | |
251 | | -| count | c | Number | 1 | Number of generated strings | |
252 | | - |
| 11 | +Available commands are [`string`, `pick`, `shuffle`, `id`]. |
253 | 12 |
|
254 | 13 | ## Feature requests and bug reports |
255 | | -If you have a bug or have a goode idea for a new feature, please [open an issue](https://github.com/AmrSaber/rand-string/issues). |
| 14 | +If you have a bug or have a goode idea for a new feature, please [open an issue](https://github.com/AmrSaber/rand-string/issues). |
0 commit comments