Skip to content

Commit ab00cec

Browse files
committed
update help and fix spelling
1 parent 3c40e12 commit ab00cec

File tree

3 files changed

+31
-31
lines changed

3 files changed

+31
-31
lines changed

README.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
# tf - command-line time formatter
1+
# tf - CLI Unix Time formatter
22

3-
`tf` scans for epoch times in input and outputs them
3+
`tf` scans for UNIX epoch times in input and outputs them
44
as human readable strings to stdout.
55

66
```
77
$ cat log.txt
88
[1524241219] Time is on my side
99
[1555777220] Yes it is
10-
[1587399621] A time in ecpoch millis: 1637419929123
11-
[1618935621] A time in ecpoch nanos: 1637419929123456789
10+
[1587399621] A time in epoch millis: 1637419929123
11+
[1618935621] A time in epoch nanos: 1637419929123456789
1212
1313
$ tf -g log.txt
1414
[12:20:19] Time is on my side
1515
[12:20:20] Yes it is
16-
[12:20:21] A time in ecpoch millis: 09:52:09.123
17-
[12:20:21] A time in ecpoch nanos: 09:52:09.123456789
16+
[12:20:21] A time in epoch millis: 09:52:09.123
17+
[12:20:21] A time in epoch nanos: 09:52:09.123456789
1818
```
1919

2020
## Usage
2121

2222
```
2323
$ tf --help
24-
usage: ./tf <options> [file1 [file2 [...]]]
24+
usage: tf <options> [file1 [file2 [...]]]
2525
26-
Time Formatter
26+
UNIX Time Formatter (tf)
2727
28-
Scans for epoch times in input and outputs them
28+
Scans for UNIX epoch times in input and outputs them
2929
as human readable strings to stdout.
3030
3131
10-digits are interpreted as seconds, 13 as milliseconds,
@@ -34,18 +34,18 @@ as human readable strings to stdout.
3434
If no filenames or only '-' is passed, stdin is processed.
3535
3636
examples:
37-
$ echo 1637421447 | tf
38-
$ tf -g log.txt | head
37+
$ echo 1637421447 | tf
38+
$ tf -g log.txt | head
3939
4040
The time formatting uses Golang Time.Format layouts:
4141
https://pkg.go.dev/time#Time.Format
4242
4343
options:
4444
-b, --block use block buffering (default: line buffering)
4545
-z, --block-size uint32 block buffer size (default 4096)
46-
-d, --date default format with date: '2006-01-02 15:04:05'
47-
-f, --format string golang Time.Format string (default: '15:04:05')
48-
-g, --global global match
46+
-d, --date output with date, same as --format '2006-01-02 15:04:05'
47+
-f, --format string output with Golang Time.Format layout (default: '15:04:05')
48+
-g, --global global match (default: convert only first match in line)
4949
-h, --help show help
5050
```
5151

@@ -71,35 +71,35 @@ Raw log:
7171
$ cat log.txt
7272
[1524241219] Time is on my side
7373
[1555777220] Yes it is
74-
[1587399621] A time in ecpoch millis: 1637419929123
75-
[1618935621] A time in ecpoch nanos: 1637419929123456789
74+
[1587399621] A time in epoch millis: 1637419929123
75+
[1618935621] A time in epoch nanos: 1637419929123456789
7676
```
7777

7878
Basic usage, piping from `stdin`:
7979
```
8080
$ cat log.txt | tf
8181
[12:20:19] Time is on my side
8282
[12:20:20] Yes it is
83-
[12:20:21] A time in ecpoch millis: 1637419929123
84-
[12:20:21] A time in ecpoch nanos: 1637419929123456789
83+
[12:20:21] A time in epoch millis: 1637419929123
84+
[12:20:21] A time in epoch nanos: 1637419929123456789
8585
```
8686

8787
Date conversion:
8888
```
8989
$ tf -d log.txt
9090
[2018-04-20 12:20:19] Time is on my side
9191
[2019-04-20 12:20:20] Yes it is
92-
[2020-04-20 12:20:21] A time in ecpoch millis: 1637419929123
93-
[2021-04-20 12:20:21] A time in ecpoch nanos: 1637419929123456789
92+
[2020-04-20 12:20:21] A time in epoch millis: 1637419929123
93+
[2021-04-20 12:20:21] A time in epoch nanos: 1637419929123456789
9494
````
9595
9696
Global match, converting sub-second times:
9797
```
9898
$ tf -gd log.txt
9999
[2018-04-20 12:20:19] Time is on my side
100100
[2019-04-20 12:20:20] Yes it is
101-
[2020-04-20 12:20:21] A time in ecpoch millis: 2021-11-20 09:52:09.123
102-
[2021-04-20 12:20:21] A time in ecpoch nanos: 2021-11-20 09:52:09.123456789
101+
[2020-04-20 12:20:21] A time in epoch millis: 2021-11-20 09:52:09.123
102+
[2021-04-20 12:20:21] A time in epoch nanos: 2021-11-20 09:52:09.123456789
103103
```
104104
----
105105

cmd/tf/main.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import (
1414

1515
var usageFormat string = `usage: %s <options> [file1 [file2 [...]]]
1616
17-
Time Formatter
17+
UNIX Time Formatter (tf)
1818
19-
Scans for epoch times in input and outputs them
19+
Scans for UNIX epoch times in input and outputs them
2020
as human readable strings to stdout.
2121
2222
10-digits are interpreted as seconds, 13 as milliseconds,
@@ -25,8 +25,8 @@ as human readable strings to stdout.
2525
If no filenames or only '-' is passed, stdin is processed.
2626
2727
examples:
28-
$ echo 1637421447 | tf
29-
$ tf -g log.txt | head
28+
$ echo 1637421447 | tf
29+
$ tf -g log.txt | head
3030
3131
The time formatting uses Golang Time.Format layouts:
3232
https://pkg.go.dev/time#Time.Format
@@ -91,11 +91,11 @@ func main() {
9191
var useDate bool
9292
var showHelp bool
9393

94-
pflag.StringVarP(&g_outputFormat, "format", "f", "", fmt.Sprintf("golang Time.Format string (default: '%s')", DEFAULT_FORMAT))
95-
pflag.BoolVarP(&g_globalMatch, "global", "g", false, "global match")
94+
pflag.StringVarP(&g_outputFormat, "format", "f", "", fmt.Sprintf("output with Golang Time.Format layout (default: '%s')", DEFAULT_FORMAT))
95+
pflag.BoolVarP(&g_globalMatch, "global", "g", false, "global match (default: convert only first match in line)")
9696
pflag.BoolVarP(&g_blockBuffering, "block", "b", false, "use block buffering (default: line buffering)")
9797
pflag.Uint32VarP(&g_blockBufferSize, "block-size", "z", DEFAULT_BLOCK_BUFFER_SIZE, "block buffer size")
98-
pflag.BoolVarP(&useDate, "date", "d", false, fmt.Sprintf("default format with date: '%s'", DEFAULT_FORMAT_WITH_DATE))
98+
pflag.BoolVarP(&useDate, "date", "d", false, fmt.Sprintf("output with date, same as --format '%s'", DEFAULT_FORMAT_WITH_DATE))
9999
pflag.BoolVarP(&showHelp, "help", "h", false, "show help")
100100
pflag.Parse()
101101

log.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[1524241219] Time is on my side
22
[1555777220] Yes it is
3-
[1587399621] A time in ecpoch millis: 1637419929123
4-
[1618935621] A time in ecpoch nanos: 1637419929123456789
3+
[1587399621] A time in epoch millis: 1637419929123
4+
[1618935621] A time in epoch nanos: 1637419929123456789

0 commit comments

Comments
 (0)