From owner-svn-src-head@FreeBSD.ORG Sat Jun 13 17:57:47 2015 Return-Path: Delivered-To: svn-src-head@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DB52B7B7; Sat, 13 Jun 2015 17:57:46 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-ig0-x229.google.com (mail-ig0-x229.google.com [IPv6:2607:f8b0:4001:c05::229]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9F7E8A15; Sat, 13 Jun 2015 17:57:46 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: by igboe5 with SMTP id oe5so4497691igb.1; Sat, 13 Jun 2015 10:57:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=HGzaqu3wsdFbHSa7WzLFYFREYLH232RgyD1SE175q1k=; b=OjdcrpNSR7a8x/h5EsqaLbSg3D8wq9Ru+vL99vb4lQSWQp1fUkuipBrO7fw5lyGhe1 crccSGgAA6xXhs5eng+5ISWhwhmhnQTcK1/7/I/HYDM0AxJxw+A1dS6dUJyKfglwWi83 ZvEOVXdbZN04zJTt61t5rGphEFHOfTf4zeBq7q9vBD63YkUmahrWmUBByU5bJvfSoVlI M4sVoz4aVVyI0sx1rwHk3K1GIyhZOAlje8PRfJRtLIuw2DxEvuaW6rHKUJlcl7S8RmxQ KHVCZB7blNziYkNWx7T0VusVaZSxpiqpe6paRCXtT4WcTyoEU6eDnIYBn5jmCM9IsrzZ flNg== MIME-Version: 1.0 X-Received: by 10.50.79.167 with SMTP id k7mr11436952igx.32.1434218266189; Sat, 13 Jun 2015 10:57:46 -0700 (PDT) Sender: adrian.chadd@gmail.com Received: by 10.36.38.133 with HTTP; Sat, 13 Jun 2015 10:57:46 -0700 (PDT) In-Reply-To: <5D5E9A5C-0B8D-4194-9DB3-DB73253DF943@xcllnt.net> References: <201506100127.t5A1RdX6051959@svn.freebsd.org> <20150612204309.11dd3391@kan> <20150613024916.GA98218@troutmask.apl.washington.edu> <1434208622.1415.57.camel@freebsd.org> <1434210429.1415.65.camel@freebsd.org> <656256CF-58BF-492B-BA66-49B095407E9A@xcllnt.net> <5D5E9A5C-0B8D-4194-9DB3-DB73253DF943@xcllnt.net> Date: Sat, 13 Jun 2015 10:57:46 -0700 X-Google-Sender-Auth: hQRRPu7AyxO57A44QSCNprv_7xM Message-ID: Subject: Re: svn commit: r284198 - head/bin/ls From: Adrian Chadd To: Marcel Moolenaar Cc: Ian Lepore , David Chisnall , Steve Kargl , Alexander Kabaev , Marcel Moolenaar , "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Jun 2015 17:57:47 -0000 On 13 June 2015 at 10:06, Marcel Moolenaar wrote: > >> On Jun 13, 2015, at 12:35 PM, Adrian Chadd wrote: >> >> Hi, >> >> I think we're at the point now where it's worth doing that >> re-evaluation. I don't think it's worth backing everything out; just >> whether the current approach of overriding printing the way it's done >> is the right way. >> >> So, how about that happens nowish before more things are converted? > > What do you suggest we do instead? So a lot of these things are table driven. Having manual printing for tabular data is plain stupid. The libbsdstat library for doing basic statistics output with "now" and "time series" is what I'm playing with right now. It's only used by sam's wifi utilities, but I'm going to try and extend it for other utilities too (like netstat, vmstat, etc style output.) That way what's expressed in code is organised as such: * a bit of code fetches statistics * a bit of code sets up what the name of each field is, and what the units are * a bit of code handles any odd corner cases with data representations * libbsdstat takes care of recording the samples into the time-series or 'now' section, figuring out which fields need to be printed in which order, what the formatting is, etc. * .. I'm extending it to print out json for its table outputs versus just plain text. Having arbitrary formatting, arbitrary printing, random places where statistics are fetched, etc is actually the terrible problem that we could do better, without losing our minds by overcomplicating it with C++, templating, grammars, etc - and ending up with what look like five layers of nested java classes that do "Setter(ToString(Getter())" in layers. -adrian