[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Line wrapping in YAML output

From: James Rowe
Subject: Re: Line wrapping in YAML output
Date: Mon, 15 Jun 2020 12:17:27 +0100
User-agent: NeoMutt/20180716

* Eric Wong (e@80x24.org) wrote:
> James Rowe <jnrowe@gmail.com> wrote:
> >   I routinely find myself needing to use a “real language” when I want
> > to perform a quick hack with dtas purely to workaround the default line
> > wrapping in YAML output.  With unwrapped output sed/awk would often be
> > a viable solution from the shell prompt.
> Understandable.  Do you use dtas-ctl or some other socket tool?

  Pretty much always parsing dtas-ctl, because I hardly ever seem to
have a {nc,socat}-style tool with SOCK_SEQPACKET support.

> On the flip side, one of the reasons I picked YAML over JSON is
> the indented + wrapped-by-default nature made it
> $EDITOR-friendly.

  I hadn’t thought it through all that much, which is why I was asking
about possible drawbacks.

  You’ve pushed me enough to think that dropping a yaml2json¹ script in
~/bin would often be enough for many of my use cases.  That simple
change would allow fancy jid²/jq³ support along with hacky sed/awk

> >   Given that psych supports an options mapping where setting
> > ``line_width: -1`` disables wrapping entirely, I’m wondering if there
> > would be support for disabling the line wrapping.  I’m also wondering if
> > I’m missing some drawbacks to doing so.
> My patch below seems to work.  The dtas-*edit tools had to be
> updated for $EDITOR-friendliness.

  Oh wow, thanks!  WFM, but I’ll add that I didn’t expect you to do the
work ;)

> dtas-ctl output could become difficult-to-read on the terminal;
> maybe it could detect stdout is a terminal and rewrap in that
> case.

  I’m not really a fan of fiddling with behaviour on isatty(), as it
quietly changes behaviour when you’re perhaps not expecting it.  Lots of
tools do it though, so perhaps it is just me.

  So… I’m not unsure whether I still want this change.  There are
workarounds with few drawbacks, and nobody else appears to have
complained in the previous seven years about this.



1. ``puts JSON.pretty_generate(YAML.load(STDIN.read))`` in the laziest
2. https://github.com/simeji/jid/
3. https://github.com/stedolan/jq/

Attachment: signature.asc
Description: PGP signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]