Skip to content

Commit 06e6c4b

Browse files
committed
docs: added markdown for tools
Added markdown for several tools inside the cli small fix
1 parent 2d98437 commit 06e6c4b

17 files changed

Lines changed: 308 additions & 27 deletions

tools/base64.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
2-
# Tool base64
3-
4-
base64 utility acts as a base64 decoder when passed the --decode (or -d) flag and as a base64 encoder
5-
otherwise. As a decoder it only accepts raw base64 input and as an encoder it does not produce the framing
6-
lines. base64 reads standard input or file if it is provided and writes to standard output. Options
7-
--wrap (or -w) and --ignore-garbage (or -i) are accepted for compatibility with GNU base64, but the latter
8-
is unimplemented and silently ignored.
1+
`base64` utility acts as a base64 decoder when passed the `--decode` (or -d) flag and as a base64 encoder
2+
otherwise. As a decoder it only accepts raw base64 input and as an encoder it does not produce the framing
3+
lines.
94

105
```text
116
Usage:
@@ -22,16 +17,26 @@ Usage:
2217

2318
## Examples
2419

25-
### Encoding:
20+
### Encoding
2621

2722
```bash
2823
ops -base64 -e "OpenServerless is wonderful"
24+
```
25+
26+
This will output:
27+
28+
```text
2929
T3BlblNlcnZlcmxlc3MgaXMgd29uZGVyZnVs
3030
```
3131

32-
### Decoding:
32+
### Decoding
3333

3434
```bash
35-
$ ops -base64 -d "T3BlblNlcnZlcmxlc3MgaXMgd29uZGVyZnVs"
35+
ops -base64 -d "T3BlblNlcnZlcmxlc3MgaXMgd29uZGVyZnVs"
36+
```
37+
38+
This will output:
39+
40+
```text
3641
OpenServerless is wonderful
3742
```

tools/echoif.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
`echoif` is a utility that echoes the value of `<a>` if the exit code of the previous command is 0,
2+
echoes the value of `<b>` otherwise
3+
4+
```text
5+
Usage:
6+
ops -echoif <a> <b>
7+
```
8+
9+
## Example
10+
```bash
11+
$( exit 1 ); ops -echoif "0" "1"
12+
1
13+
```
14+
15+
or
16+
17+
```bash
18+
$( exit 0 ); ops -echoif "0" "1"
19+
0
20+
```

tools/echoifempty.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
`echoifempty` is a utility that echoes the value of `<a>` if `<str>` is empty, echoes the value of `<b>` otherwise.
2+
3+
```text
4+
Usage:
5+
ops -echoifempty <str> <a> <b>
6+
```
7+
8+
## Example
9+
10+
```bash
11+
ops -echoifempty "not empty string" "string is empty" "string is not empty"
12+
```

tools/echoifexists.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
echoifexists is a utility that echoes the value of `<a>` if `<file>` exists, echoes the value of `<b>` otherwise.
2+
3+
```text
4+
Usage:
5+
ops -echoifexists <file> <a> <b>
6+
```
7+
8+
## Example
9+
10+
```bash
11+
ops -echoifexists "exists" "doesn't exists"
12+
```

tools/empty.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
`empty` creates an empty file - returns error if it already exists.
2+
3+
```text
4+
Usage:
5+
ops -empty <filename>
6+
```
7+
8+
## Options
9+
10+
```
11+
-h, --help Display this help message
12+
```

tools/executable.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
`executable` make a file executable: on Unix-like systems it will do a chmod u+x.
2+
On Windows systems it will rename the file to .exe if needed.
3+
4+
```text
5+
Usage:
6+
ops -executable <filename>
7+
```
8+
## Example
9+
10+
```bash
11+
ops -executable kind
12+
```

tools/extract.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Extract one single file from a .zip .tar, .tgz, .tar.gz, tar.bz2, tar.gz.
2+
3+
```text
4+
Usage:
5+
ops -extract file.(zip|tgz|tar[.gz|.bz2|.xz]) target
6+
```
7+
8+
## Example
9+
10+
Extract file named `single.pdf` from `archive.zip` archive.
11+
12+
```bash
13+
ops -extract archive.zip single.pdf
14+
```

tools/filetype.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Show extension and MIME type of a file.
2+
Supported types are documented [here](https://github.com/h2non/filetype?tab=readme-ov-file#supported-types)
3+
4+
```text
5+
Usage:
6+
ops -filetype [-h] [-e] [-m] FILE
7+
```
8+
9+
## Options
10+
11+
```
12+
-h shows this help
13+
-e show file standard extension
14+
-m show file mime type
15+
```
16+
17+
## Examples
18+
19+
### File Mime type
20+
21+
```bash
22+
ops -filetype -m `which ops`
23+
```
24+
25+
This will output the ops executable type:
26+
``application/x-mach-binary`` or `application/x-executable`
27+

tools/needupdate.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
Check if a semver version A > semver version B.
2+
Exits with 0 if greater, 1 otherwise.
3+
4+
```text
5+
Usage:
6+
ops -needupdate <versionA> <versionB>
7+
```
8+
9+
## Options
10+
11+
```
12+
-h, --help print this help info
13+
```
14+
15+
## Examples
16+
17+
### Update is needed
18+
19+
```bash
20+
ops -needupdate 1.0.1 1.0.0; echo $?
21+
```
22+
23+
This will output:
24+
25+
```text
26+
0
27+
```
28+
29+
### Update is not needed
30+
31+
```bash
32+
ops -needupdate 1.0.0 1.0.1; echo $?
33+
```
34+
35+
This will output:
36+
37+
```text
38+
1
39+
```

tools/random.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Generate random numbers, strings and uuids
2+
3+
```text
4+
Usage:
5+
ops -random [options]
6+
```
7+
8+
## Options
9+
10+
```
11+
-h, --help shows this help
12+
-u, --uuid generates a random uuid v4
13+
--int <max> [min] generates a random non-negative integer between min and max (default min=0)
14+
--str <len> [<characters>] generates an alphanumeric string of length <len> from the set of <characters> provided (default <characters>=a-zA-Z0-9)
15+
```
16+
17+
## Examples
18+
19+
### Random uuid v4:
20+
21+
```bash
22+
ops -random -u
23+
```
24+
25+
This will output something like:
26+
27+
```text
28+
5b2c45ef-7d15-4a15-84c6-29144393b621
29+
```
30+
31+
### Random integer between max and min
32+
```bash
33+
ops -random --int 100 60
34+
```
35+
36+
This will output something like:
37+
38+
```text
39+
78
40+
```

0 commit comments

Comments
 (0)