From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 2598F1F5AE for ; Tue, 16 Jun 2020 04:19:47 +0000 (UTC) Received: from localhost ([::1]:45306 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jl34c-0003Gw-1D for e@80x24.org; Tue, 16 Jun 2020 00:19:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52496) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jl34a-0003Gq-LX for dtas-all@nongnu.org; Tue, 16 Jun 2020 00:19:44 -0400 Received: from dcvr.yhbt.net ([64.71.152.64]:40250) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jl34Y-0008Ky-OZ for dtas-all@nongnu.org; Tue, 16 Jun 2020 00:19:44 -0400 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id BD0FC1F5AE; Tue, 16 Jun 2020 04:19:38 +0000 (UTC) Date: Tue, 16 Jun 2020 04:19:38 +0000 From: Eric Wong To: dtas-all@nongnu.org Subject: Re: Line wrapping in YAML output Message-ID: <20200616041938.GA7549@dcvr> References: <20200613152543.owwp2ey3byvf2row@gmail.com> <20200615002434.GA30135@dcvr> <20200615111727.yn23ntg6spxa7ft4@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200615111727.yn23ntg6spxa7ft4@gmail.com> Received-SPF: pass client-ip=64.71.152.64; envelope-from=e@80x24.org; helo=dcvr.yhbt.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/16 00:19:39 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: dtas-all@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: duct tape audio suite List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dtas-all-bounces+e=80x24.org@nongnu.org Sender: "dtas-all" James Rowe wrote: > * Eric Wong (e@80x24.org) wrote: > > James Rowe 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. It's not well-documented, but socat supports setting type= to the numeric value of SOCK_SEQPACKET. At least on Linux, SOCK_SEQPACKET is 5 (ruby -rsocket -e 'puts Socket::SOCK_SEQPACKET'): echo current | socat UNIX-CONNECT:$HOME/.dtas/player.sock,type=5 - > > 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 > scripts. Cool. Fwiw, I also just found "yq" looking for a jq-like thing for YAML: https://kislyuk.github.io/yq/ I haven't tried yq, and have no plans to: I prefer to avoid software unless it's been in Debian for a while. > > > 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 ;) No problem, I was curious how long much effort it took and it wasn't much, at all. > > 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. Yeah, it's a bit surprising sometimes. I often run commands in my $EDITOR buffer and it wouldn't help that case. > So… I’m not unsure whether I still want this change. There are "not unsure"? Based on the rest of what you've written, I think you meant just to write either "unsure" or "not sure"? > workarounds with few drawbacks, and nobody else appears to have > complained in the previous seven years about this. AFAIK, you're maybe the 3rd user of this? :) I'm not exactly good at promoting software and have no plans to break out of my introvert comfort zone :> Anyways, I'm not inclined to change this, either; since reformatting YAML or converting to JSON is pretty easy in Ruby/Perl/Python.