From owner-freebsd-arch@FreeBSD.ORG Mon Aug 18 13:11:51 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 1BFDAFA4; Mon, 18 Aug 2014 13:11:51 +0000 (UTC) Received: from na01-by2-obe.outbound.protection.outlook.com (mail-by2lp0243.outbound.protection.outlook.com [207.46.163.243]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mail.protection.outlook.com", Issuer "MSIT Machine Auth CA 2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A9F7B3737; Mon, 18 Aug 2014 13:11:49 +0000 (UTC) Received: from BY2PR05CA030.namprd05.prod.outlook.com (10.141.250.20) by DM2PR05MB736.namprd05.prod.outlook.com (10.141.178.25) with Microsoft SMTP Server (TLS) id 15.0.1010.18; Mon, 18 Aug 2014 13:11:46 +0000 Received: from BY2FFO11FD058.protection.gbl (2a01:111:f400:7c0c::107) by BY2PR05CA030.outlook.office365.com (2a01:111:e400:2c5f::20) with Microsoft SMTP Server (TLS) id 15.0.1010.18 via Frontend Transport; Mon, 18 Aug 2014 13:11:46 +0000 Received: from P-EMF01-SAC.jnpr.net (66.129.239.15) by BY2FFO11FD058.mail.protection.outlook.com (10.1.15.178) with Microsoft SMTP Server (TLS) id 15.0.1010.11 via Frontend Transport; Mon, 18 Aug 2014 13:11:46 +0000 Received: from magenta.juniper.net (172.17.27.123) by P-EMF01-SAC.jnpr.net (172.24.192.21) with Microsoft SMTP Server (TLS) id 14.3.146.0; Mon, 18 Aug 2014 06:11:45 -0700 Received: from idle.juniper.net (idleski.juniper.net [172.25.4.26]) by magenta.juniper.net (8.11.3/8.11.3) with ESMTP id s7IDBbn83317; Mon, 18 Aug 2014 06:11:38 -0700 (PDT) (envelope-from phil@juniper.net) Received: from idle.juniper.net (localhost [127.0.0.1]) by idle.juniper.net (8.14.4/8.14.3) with ESMTP id s7IDBRtD018629; Mon, 18 Aug 2014 09:11:27 -0400 (EDT) (envelope-from phil@idle.juniper.net) Message-ID: <201408181311.s7IDBRtD018629@idle.juniper.net> To: Stefan Esser Subject: Re: XML Output: libxo - provide single API to output TXT, XML, JSON and HTML In-Reply-To: <53F1A311.4080707@freebsd.org> Date: Mon, 18 Aug 2014 09:11:27 -0400 From: Phil Shafer MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:66.129.239.15; CTRY:US; IPV:NLI; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(6009001)(199003)(164054003)(189002)(20776003)(64706001)(47776003)(79102001)(76482001)(15202345003)(87936001)(68736004)(76506005)(92566001)(69596002)(84676001)(46102001)(53416004)(77982001)(15975445006)(92726001)(80022001)(6806004)(21056001)(86362001)(102836001)(85306004)(44976005)(4396001)(97736001)(103666002)(83322001)(19580395003)(83072002)(50466002)(54356999)(50986999)(81342001)(81542001)(99396002)(107046002)(48376002)(106466001)(31966008)(74502001)(81156004)(105596002)(110136001)(95666004)(74662001); DIR:OUT; SFP:; SCL:1; SRVR:DM2PR05MB736; H:P-EMF01-SAC.jnpr.net; FPR:; MLV:sfv; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;UriScan:; X-Forefront-PRVS: 03077579FF Received-SPF: SoftFail (protection.outlook.com: domain of transitioning juniper.net discourages use of 66.129.239.15 as permitted sender) Authentication-Results: spf=softfail (sender IP is 66.129.239.15) smtp.mailfrom=phil@juniper.net; X-OriginatorOrg: juniper.net Cc: Marcel Moolenaar , John-Mark Gurney , Alfred Perlstein , "Simon J. Gerraty" , "arch@freebsd.org" , Poul-Henning Kamp , Konstantin Belousov , Marcel Moolenaar X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Aug 2014 13:11:51 -0000 Stefan Esser writes: >Is it possible to introduce a "xo" command which takes a command >line as an argument (in the same way as e.g. "time"). A sample >usage could be "xo ls -s", which should invoke "ls -l" with its >output converted to XML (and "xo -json ls -l" could produce JSON >output). I've implemented the "--libxo" option, in a function called xo_parse_args(), that it called before getopt* and processes and removes libxo options. See the example on: http://juniper.github.io/libxo/libxo-manual.html FWIW, there's an "xo" command packaged with libxo that perform similar to the printf(1) command: % xo --wrap top/data 'My {:pet} is {:age} years old\n' dog 2 My dog is 2 years old % xo --xml --pretty --wrap top/data 'My {:pet} is {:age} years old\n' dog 2 dog 2 Thanks, Phil