From owner-freebsd-arch@FreeBSD.ORG Thu Jul 31 16:41:07 2014 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B84EB709; Thu, 31 Jul 2014 16:41:07 +0000 (UTC) Received: from smtp9.server.rpi.edu (gateway.canit.rpi.edu [128.113.2.229]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5CB092876; Thu, 31 Jul 2014 16:41:06 +0000 (UTC) Received: from smtp-auth2.server.rpi.edu (smtp-auth2.server.rpi.edu [128.113.2.232]) by smtp9.server.rpi.edu (8.14.3/8.14.3/Debian-9.4) with ESMTP id s6VGf4CL004714; Thu, 31 Jul 2014 12:41:05 -0400 Received: from smtp-auth2.server.rpi.edu (localhost [127.0.0.1]) by smtp-auth2.server.rpi.edu (Postfix) with ESMTP id C015F1814F; Thu, 31 Jul 2014 12:41:04 -0400 (EDT) Received: from [128.113.24.47] (gilead-qc124.netel.rpi.edu [128.113.124.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: drosih) by smtp-auth2.server.rpi.edu (Postfix) with ESMTPSA id AF98C180BD; Thu, 31 Jul 2014 12:41:04 -0400 (EDT) From: "Garance A Drosehn" To: "Phil Shafer" Subject: Re: XML Output: libxo - provide single API to output TXT, XML, JSON and HTML Date: Thu, 31 Jul 2014 12:41:03 -0400 Message-ID: <08B4AE10-1747-4BB1-AA1A-BA4491A57F95@rpi.edu> In-Reply-To: <201407310918.s6V9IRj5092988@idle.juniper.net> References: <201407310918.s6V9IRj5092988@idle.juniper.net> MIME-Version: 1.0 X-Mailer: MailMate (1.7.2r3905) X-Virus-Scanned: ClamAV using ClamSMTP X-Bayes-Prob: 0.0001 (Score 0, tokens from: outgoing, @@RPTN) X-Spam-Score: 0.00 () [Hold at 15.10] X-CanIt-Incident-Id: 02Mx4F4E5 X-CanIt-Geo: ip=128.113.124.17; country=US; region=New York; city=Troy; latitude=42.7495; longitude=-73.5951; http://maps.google.com/maps?q=42.7495,-73.5951&z=6 X-CanItPRO-Stream: outgoing X-Canit-Stats-ID: Bayes signature not available X-Scanned-By: CanIt (www . roaringpenguin . com) on 128.113.2.229 Cc: arch@freebsd.org, marcel@freebsd.org, "Simon J. Gerraty" X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Jul 2014 16:41:07 -0000 On 31 Jul 2014, at 5:18, Phil Shafer wrote: > "Simon J. Gerraty" writes: >> w(1) sizes those strings based on its expectation of the width of the >> tty. That can obviously be fixed/improved - but involves exposing >> knowledge of the out format (or at least that it isn't TXT) to the >> application. > > libxo allows the field description to carry two distinct format > descriptors, one for text/html and one for xml/json. The latter > defaults to the former: > > xo_emit(" {:words/%7ju/%ju}", twordct); > > For "w", this is does the right thing; in text mode, the command > string is truncated: Ah, that's helpful. What if there's something you want to print out for xml/json but *not* for plain-text? (it's easy to imagine some commands might print out more values when they are not constrained by an 80-char width). Also, given that machine-readable outputs might change over time, is there the idea of including a version-number with the output for each command? I hope it doesn't seem like I'm just complaining about the work everyone else is doing (both this and the GSOC project). Please note that I've attempted to do this a few times myself, and I haven't been happy with any of *my* attempts either! -- Garance Alistair Drosehn = drosih@rpi.edu Senior Systems Programmer or gad@FreeBSD.org Rensselaer Polytechnic Institute; Troy, NY; USA