From owner-freebsd-arch@FreeBSD.ORG Tue May 4 10:58:16 2010 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C69A61065678 for ; Tue, 4 May 2010 10:58:16 +0000 (UTC) (envelope-from gljennjohn@googlemail.com) Received: from mail-fx0-f54.google.com (mail-fx0-f54.google.com [209.85.161.54]) by mx1.freebsd.org (Postfix) with ESMTP id 50D118FC1A for ; Tue, 4 May 2010 10:58:15 +0000 (UTC) Received: by fxm15 with SMTP id 15so3460535fxm.13 for ; Tue, 04 May 2010 03:58:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:in-reply-to:references:reply-to:x-mailer:mime-version :content-type:content-transfer-encoding; bh=gbJ0hDjWB0F5IUZZ79vNPBDLT9DHpTFw5OWYGEFdmwg=; b=K//HuJXgDxf6qMJitip9sGCZ2qkDKCYq0hY+8EdpJEvgGvfhnrNOvDSvHIZnJrt0Ai epvBY9tI4Y9l3RUx6uuk2xJTdoEbCWKEdGdf7MOCiyo6lu2yHaIgGZz5fq+6fZ3WxR31 cVMDHlrTLzdVn9dtRS0QugIDZjvZnVL6/dIJw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=date:from:to:cc:subject:message-id:in-reply-to:references:reply-to :x-mailer:mime-version:content-type:content-transfer-encoding; b=OW60Ofsu3j2WoKjU7SCb0ODXKdjQ7qd29LW8Ji9XNHlsabX2ObijynkZuN6LkaD7md iGqjSFo9q8EeU1OdHzMoDM5WlPDCmxKeA9DfZHBVvN6bk+a2EpoY4KrR9uQlotdnliPN edAMeowXKqbId/1rjegVZEUjIho41ZfXi+BLw= Received: by 10.223.97.149 with SMTP id l21mr3979615fan.91.1272968791526; Tue, 04 May 2010 03:26:31 -0700 (PDT) Received: from ernst.jennejohn.org (p57AE21EB.dip0.t-ipconnect.de [87.174.33.235]) by mx.google.com with ESMTPS id 35sm11131921fkt.37.2010.05.04.03.26.30 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 04 May 2010 03:26:31 -0700 (PDT) Date: Tue, 4 May 2010 12:26:29 +0200 From: Gary Jennejohn To: Peter Jeremy Message-ID: <20100504122629.0aa4c2dc@ernst.jennejohn.org> In-Reply-To: <20100504091749.GA58464@server.vk2pj.dyndns.org> References: <20100504091749.GA58464@server.vk2pj.dyndns.org> X-Mailer: Claws Mail 3.7.5 (GTK+ 2.18.7; amd64-portbld-freebsd9.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: freebsd-arch@freebsd.org Subject: Re: Style question: writing multi-line usage messages X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: gljennjohn@googlemail.com List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 May 2010 10:58:16 -0000 On Tue, 4 May 2010 19:17:49 +1000 Peter Jeremy wrote: > I would appreciate some input on the preferred style for writing > multi-line usage messages. Should: > 1) printf() print a series of 1-line strings > 2) should string gluing be used to turn multiple strings into one for printing > 3) should continuation lines be used to create a single string > > I can't see anything in style(9) to cover this. > > Variants of the tunefs(8) usage() function follow as examples: > > void > usage(void) > { > > fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n", > "usage: tunefs [-A] [-a enable | disable] [-e maxbpg] [-f avgfilesize]", > " [-J enable | disable] [-j enable | disable]", > " [-L volname] [-l enable | disable] [-m minfree]", > " [-N enable | disable] [-n enable | disable]", > " [-o space | time] [-p] [-S size] [-s avgfpdir]", > " special | filesystem"); > exit(2); > } > This version requires you to remmeber to add %s\n to the format if you add a new line, something which I personally forget to do all the time. > void > usage(void) > { > > fprintf(stderr, > "usage: tunefs [-A] [-a enable | disable] [-e maxbpg] [-f avgfilesize]\n" > " [-J enable | disable] [-j enable | disable]\n" > " [-L volname] [-l enable | disable] [-m minfree]\n" > " [-N enable | disable] [-n enable | disable]\n" > " [-o space | time] [-p] [-S size] [-s avgfpdir]\n" > " special | filesystem\n"); > exit(2); > } > > void > usage(void) > { > > fprintf(stderr, > "usage: tunefs [-A] [-a enable | disable] [-e maxbpg] [-f avgfilesize]\n\ > [-J enable | disable] [-j enable | disable]\n\ > [-L volname] [-l enable | disable] [-m minfree]\n\ > [-N enable | disable] [-n enable | disable]\n\ > [-o space | time] [-p] [-S size] [-s avgfpdir]\n\ > special | filesystem\n"); > exit(2); > } > I personally don't see all that much difference between these. The first variant has the advantage that it's very clear that you're looking at strings, which might be a good thing. I vote for 2. Couldn't you replace all the leading spaces with \t's? -- Gary Jennejohn