-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Fast stdin display, lower memory usage, follow/reverse mode, ho…
…me/end key support. long help support (#85) Signed-off-by: Hiram Chirino <[email protected]> Co-authored-by: Maksym Kryvchun <[email protected]>
- Loading branch information
Showing
44 changed files
with
1,094 additions
and
1,115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ bin | |
|
||
# IDE | ||
.vscode | ||
.idea | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
time=2024-08-19T15:06:16.848-04:00 level=INFO msg="case <-eofEvent" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//go:build !mock_stdin | ||
|
||
package main | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"io" | ||
"io/fs" | ||
"os" | ||
) | ||
|
||
func getStdinReader(defaultInput fs.File) (io.Reader, error) { | ||
stat, err := defaultInput.Stat() | ||
if err != nil { | ||
return nil, fmt.Errorf("stat: %w", err) | ||
} | ||
|
||
if stat.Mode()&os.ModeCharDevice != 0 { | ||
return bytes.NewReader(nil), nil | ||
} | ||
|
||
return defaultInput, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//go:build mock_stdin | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
"io/fs" | ||
"os" | ||
"time" | ||
) | ||
|
||
func getStdinReader(defaultInput fs.File) (io.Reader, error) { | ||
r, w, err := os.Pipe() | ||
if err != nil { | ||
return nil, fmt.Errorf("pipe: %w", err) | ||
} | ||
go func() { | ||
defer w.Close() | ||
for i := 0; ; i++ { | ||
_, err := w.Write([]byte(fmt.Sprintf(`{"message": "Line %d"} | ||
`, i))) | ||
if err != nil { | ||
fatalf("Write failed: %s\n", err) | ||
} | ||
time.Sleep(10 * time.Millisecond) | ||
} | ||
}() | ||
return r, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.