alexherbo2 / kakoune.cr

A command-line tool for Kakoune
https://kakoune.org
The Unlicense
54 stars 11 forks source link

kcr send - error when trying to read from stdin #30

Closed ghost closed 3 years ago

ghost commented 3 years ago

I am trying to use the command echo nop | kcr send - but this fails and outputs the following error:

Unhandled exception: Unexpected char 'p' at line 1, column 1 (JSON::ParseException)
  from /usr/share/crystal/src/json/lexer.cr:376:7 in 'raise'
  from /usr/share/crystal/src/json/lexer.cr:372:5 in 'unexpected_char'
  from /usr/share/crystal/src/json/lexer.cr:371:11 in 'unexpected_char'
  from /usr/share/crystal/src/slice.cr:225:5 in 'next_token'
  from /usr/share/crystal/src/json/pull_parser.cr:638:11 in 'initialize'
  from /usr/share/crystal/src/json/from_json.cr:13:3 in 'add'
  from src/cli.cr:430:9 in 'start'
  from src/cli.cr:618:1 in '__crystal_main'
  from /usr/share/crystal/src/crystal/main.cr:110:5 in 'main'
  from __libc_start_main
  from _start
  from ???

I expect the command to do the same as kcr send nop

ghost commented 3 years ago

Just saw the example for this involves using kcr echo so though I might have been doing it wrong but still get the same error with the example: kcr echo -- echo kanto | kcr echo - echo johto | kcr send -

error:

Unhandled exception: Unexpected char 'k' at line 1, column 1 (JSON::ParseException)
  from /usr/share/crystal/src/json/lexer.cr:376:7 in 'raise'
  from /usr/share/crystal/src/json/lexer.cr:372:5 in 'unexpected_char'
  from /usr/share/crystal/src/json/lexer.cr:371:11 in 'unexpected_char'
  from /usr/share/crystal/src/slice.cr:225:5 in 'next_token'
  from /usr/share/crystal/src/json/pull_parser.cr:638:11 in 'initialize'
  from /usr/share/crystal/src/json/from_json.cr:13:3 in 'add'
  from src/cli.cr:430:9 in 'start'
  from src/cli.cr:618:1 in '__crystal_main'
  from /usr/share/crystal/src/crystal/main.cr:110:5 in 'main'
  from __libc_start_main
  from _start
  from ???
alexherbo2 commented 3 years ago

Good catch. I have to restore JSON Lines.

For the time being, you can --slurp the output with jq.

alexherbo2 commented 3 years ago

Added kcr send --lines.