~gpanders/ijq

0418fcb8d3f0f40de40a73011d1659914eeadf7b — Gregory Anders 3 years ago 18695f5
Ignore errors when writing to jq's stdin

This would cause ijq to crash when an invalid filter was used (this has
not always been the case, so I wonder if something changed either with
jq). Instead, also get the subprocess's stderr and display that to the
user along with its stdout.
1 files changed, 3 insertions(+), 5 deletions(-)

M main.go
M main.go => main.go +3 -5
@@ 142,12 142,10 @@ func (d *Document) Filter(filter string) (string, error) {

	go func() {
		defer stdin.Close()
		if _, err := io.WriteString(stdin, d.contents); err != nil {
			log.Fatalln(err)
		}
		_, _ = io.WriteString(stdin, d.contents);
	}()

	out, err := cmd.Output()
	out, err := cmd.CombinedOutput()
	if err != nil {
		return "", err
	}


@@ 260,7 258,7 @@ func createApp(doc Document, filter string) *tview.Application {
	go func() {
		var text string
		var timer *time.Timer
		interval := time.Millisecond
		interval := 5 * time.Millisecond
		for {
			text = <-inputChan
			if timer != nil {