util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rüdiger Meier" <sweet_f_a@gmx.de>
To: Karel Zak <kzak@redhat.com>
Cc: util-linux@vger.kernel.org
Subject: Re: [PATCH 2/6] misc: introduce PRINT_USAGE_HELP()
Date: Tue, 27 Jun 2017 12:48:44 +0200	[thread overview]
Message-ID: <e39a60ec-8aaf-de01-1d22-0064b1b2b2ed@gmx.de> (raw)
In-Reply-To: <20170627094652.fz3grdtj5qe5cmhi@ws.net.home>



On 06/27/2017 11:46 AM, Karel Zak wrote:
> On Mon, Jun 26, 2017 at 08:29:48PM +0200, Ruediger Meier wrote:
>> --- a/include/c.h
>> +++ b/include/c.h
>> @@ -315,8 +315,18 @@ static inline int xusleep(useconds_t usec)
>>   #define USAGE_COMMANDS   _("\nCommands:\n")
>>   #define USAGE_COLUMNS    _("\nAvailable output columns:\n")
>>   #define USAGE_SEPARATOR    "\n"
>> -#define USAGE_HELP       _(" -h, --help     display this help and exit\n")
>> -#define USAGE_VERSION    _(" -V, --version  output version information and exit\n")
>> +
>> +#define USAGE_HELP_TXT    _("display this help and exit")
>> +#define USAGE_VERSION_TXT _("output version information and exit")
>> +
>> +#define PRINT_USAGE_HELP(marg_dsc) \
>> +	printf( \
>> +		"%-" #marg_dsc "s%s\n" \
>> +		"%-" #marg_dsc "s%s\n" \
>> +		, " -h, --help",    USAGE_HELP_TXT \
>> +		, " -V, --version", USAGE_VERSION_TXT \
>> +	)
> 
> Would be possible to use lowercase for the macro name?
> 
> For example USAGE_HELP_TXT is fine, but for something like function I
> would prefer
> 
>   #define print_usage_help(marg_dsc)

I've updated on github to

#define USAGE_OPTSTR_HELP     _("display this help")
#define USAGE_OPTSTR_VERSION  _("print version")

#define print_usage_help_options(marg_dsc) \
	[...]

> and what about USAGE_SEPARATOR that we have always before --help?
> Maybe we can add \n to  the print_usage_help() too.

No, because

1. There are commands with help options only:

$ ctrlaltdel --help
  [...]
  Options:
  -h, --help     display this help
  -V, --version  print version

2. Since we have we help descriptions now aligned we do not need
    the separator always IMO. ipcs(1) and also others which
    still don't have separators are looking ok:

$ ipcs --help
Usage:
  ipcs [resource-option...] [output-option]
  ipcs -m|-q|-s -i <id>

Show information on IPC facilities.

Options:
  -i, --id <id>  print details on resource identified by <id>
  -h, --help     display this help
  -V, --version  print version

Resource options:
  -m, --shmems      shared memory segments
[...]

cu,
Rudi

>> --- a/login-utils/last.c
>> +++ b/login-utils/last.c
>> @@ -589,8 +589,7 @@ static void __attribute__((__noreturn__)) usage(const struct last_control *ctl)
>>   		"                               notime|short|full|iso\n"), out);
>>   
>>   	fputs(USAGE_SEPARATOR, out);
>> -	fputs(USAGE_HELP, out);
>> -	fputs(USAGE_VERSION, out);
>> +	PRINT_USAGE_HELP(22);
>>   	fprintf(out, USAGE_MAN_TAIL("last(1)"));
> 
> 
>   Karel
> 

  reply	other threads:[~2017-06-27 10:48 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-26 18:29 [PATCH 0/6] consolidate help/version option descriptions Ruediger Meier
2017-06-26 18:29 ` [PATCH 1/6] misc: revert to the old USAGE_HELP strings Ruediger Meier
2017-06-26 18:29 ` [PATCH 2/6] misc: introduce PRINT_USAGE_HELP() Ruediger Meier
2017-06-27  9:46   ` Karel Zak
2017-06-27 10:48     ` Rüdiger Meier [this message]
2017-06-27 12:19       ` Karel Zak
2017-06-26 18:29 ` [PATCH 3/6] misc: consolidate all --help option descriptions Ruediger Meier
2017-06-26 18:29 ` [PATCH 4/6] blockdev: improve --help and man page Ruediger Meier
2017-06-26 18:29 ` [PATCH 5/6] login: add --help text Ruediger Meier
2017-06-26 18:29 ` [PATCH 6/6] misc: update --help content again Ruediger Meier
2017-06-27 12:42   ` J William Piggott
2017-06-27 13:26     ` Rüdiger Meier
2017-06-27 15:12       ` J William Piggott
2017-06-27 16:35         ` Rüdiger Meier
2017-06-27 19:08           ` J William Piggott
2017-06-28 21:59             ` Ruediger Meier
2017-07-28 13:34               ` J William Piggott
2017-06-27  9:49 ` [PATCH 0/6] consolidate help/version option descriptions Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e39a60ec-8aaf-de01-1d22-0064b1b2b2ed@gmx.de \
    --to=sweet_f_a@gmx.de \
    --cc=kzak@redhat.com \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).