Skip to content

Commit

Permalink
Improve documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
riquito committed Dec 13, 2023
1 parent f971dec commit d635edd
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 21 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ OPTIONS:
Fields can be negative (-1 is the last field).
[default 1:]
e.g. cutting on '-' the string 'a-b-c-d'
e.g. cutting the string 'a-b-c-d' on '-'
-f 1 => a
-f 1: => a-b-c-d
-f 1:3 => a-b-c
Expand All @@ -66,7 +66,7 @@ OPTIONS:
You can also format the output using {} syntax
e.g.
-f '["{1}", "{2}"]' => ["a", "b"]
-f '({1}, {2})' => (a, b)
You can escape { and } using {{ and }}.
Expand Down Expand Up @@ -132,6 +132,12 @@ cba
ac
```

```sh
# Emit JSON output
echo "foo bar baz" | tuc -d ' ' --json
["foo","bar","baz"]
```

```sh
# Delimiters can be any number of characters long
echo "a<sep>b<sep>c" | tuc -d '<sep>' -f 1,3
Expand Down
17 changes: 8 additions & 9 deletions doc/tuc.1
Original file line number Diff line number Diff line change
Expand Up @@ -75,31 +75,31 @@ Print fields as a JSON array of strings
.PP
\ \ \ \ \ \ \ [default 1:]
.PP
\ \ \ \ \ \ \ e.g.\ cutting on \[aq]-\[aq] the string \[aq]a-b-c-d\[aq]
\ \ \ \ \ \ \ e.g.\ cutting the string \[aq]a-b-c-d\[aq] on \[aq]-\[aq]
.PD 0
.P
.PD
\ \ \ \ \ \ \ \ \-f 1 => a
\ \ \ \ \ \ \ \ \ \f[V]-f 1 => a\f[R]
.PD 0
.P
.PD
\ \ \ \ \ \ \ \ \-f 1: => a-b-c-d
\ \ \ \ \ \ \ \ \ \f[V]-f 1: => a-b-c-d\f[R]
.PD 0
.P
.PD
\ \ \ \ \ \ \ \ \-f 1:3 => a-b-c
\ \ \ \ \ \ \ \ \ \f[V]-f 1:3 => a-b-c\f[R]
.PD 0
.P
.PD
\ \ \ \ \ \ \ \ \-f 3,2 => cb
\ \ \ \ \ \ \ \ \ \f[V]-f 3,2 => cb\f[R]
.PD 0
.P
.PD
\ \ \ \ \ \ \ \ \-f 3,1:2 => ca-b
\ \ \ \ \ \ \ \ \ \f[V]-f 3,1:2 => ca-b\f[R]
.PD 0
.P
.PD
\ \ \ \ \ \ \ \ \-f -3:-2 => b-c
\ \ \ \ \ \ \ \ \ \f[V]-f -3:-2 => b-c\f[R]
.PP
\ \ \ \ \ \ \ To re-apply the delimiter add -j, to replace
.PD 0
Expand All @@ -115,8 +115,7 @@ Print fields as a JSON array of strings
.PD 0
.P
.PD
\ \ \ \ \ \ \ \ \ -f \[aq][\[dq]{1}\[dq], \[dq]{2}\[dq]]\[aq] =>
[\[dq]a\[dq], \[dq]b\[dq]]
\ \ \ \ \ \ \ \ \ \f[V]-f \[aq]({1}, {2})\[aq] => (a, b)\f[R]
.PP
\ \ \ \ \ \ \ You can escape { and } using {{ and }}.
.PP
Expand Down
4 changes: 2 additions & 2 deletions doc/tuc.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ OPTIONS

| [default 1:]

| e.g. cutting on \'-\' the string \'a-b-c-d\'
| e.g. cutting the string \'a-b-c-d\' on \'-\'
| `-f 1 => a`
| `-f 1: => a-b-c-d`
| `-f 1:3 => a-b-c`
Expand All @@ -72,7 +72,7 @@ OPTIONS

| You can also format the output using {} syntax
| e.g.
| -f \'[\"{1}\", \"{2}\"]\' => [\"a\", \"b\"]
| `-f '({1}, {2})' => (a, b)`

| You can escape { and } using {{ and }}.

Expand Down
16 changes: 8 additions & 8 deletions src/bin/tuc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@ OPTIONS:
Fields can be negative (-1 is the last field).
[default 1:]
e.g. cutting on '-' the string 'a-b-c-d'
-f 1 => a
-f 1: => a-b-c-d
-f 1:3 => a-b-c
-f 3,2 => cb
-f 3,1:2 => ca-b
-f -3:-2 => b-c
e.g. cutting the string 'a-b-c-d' on '-'
-f 1 => a
-f 1: => a-b-c-d
-f 1:3 => a-b-c
-f 3,2 => cb
-f 3,1:2 => ca-b
-f -3:-2 => b-c
To re-apply the delimiter add -j, to replace
it add -r (followed by the new delimiter).
You can also format the output using {} syntax
e.g.
-f '["{1}", "{2}"]' => ["a", "b"]
-f '({1}, {2})' => (a, b)
You can escape { and } using {{ and }}.
Expand Down

0 comments on commit d635edd

Please sign in to comment.