Linux-EROFS Archive on lore.kernel.org
 help / color / Atom feed
From: Gao Xiang <gaoxiang25@huawei.com>
To: Li Guifu <wylgf01@163.com>, Li Guifu <blucerlee@gmail.com>
Cc: linux-erofs@lists.ozlabs.org
Subject: Re: [PATCH v1] erofs-utils: introduce long parameter option
Date: Tue, 22 Oct 2019 10:50:53 +0800
Message-ID: <20191022025053.GA180717@architecture4> (raw)
In-Reply-To: <20191021181923.3773-1-wylgf01@163.com>

Hi Guifu,

On Tue, Oct 22, 2019 at 02:19:23AM +0800, Li Guifu wrote:
> From: Li Guifu <blucerlee@gmail.com>
> 
> Only --help|-h is uesed right now

                    ^
typo in the commit message.


> 
> Signed-off-by: Li Guifu <blucerlee@gmail.com>
> ---
>  mkfs/main.c | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/mkfs/main.c b/mkfs/main.c
> index 71c81f5..f62b065 100644
> --- a/mkfs/main.c
> +++ b/mkfs/main.c
> @@ -13,6 +13,8 @@
>  #include <limits.h>
>  #include <libgen.h>
>  #include <sys/stat.h>
> +#include <getopt.h>
> +
>  #include "erofs/config.h"
>  #include "erofs/print.h"
>  #include "erofs/cache.h"
> @@ -23,10 +25,16 @@
>  
>  #define EROFS_SUPER_END (EROFS_SUPER_OFFSET + sizeof(struct erofs_super_block))
>  
> +static struct option long_options[] = {
> +	{"help", no_argument, 0, 'h'},


How about removing '-h' from help message?
Thus we can keep '-h' for later usage instead of just print messages.

like,
	{"help", no_argument, 0, 1},


> +	{0, 0, 0, 0},
> +};
> +
>  static void usage(void)
>  {
>  	fprintf(stderr, "usage: [options] FILE DIRECTORY\n\n");
>  	fprintf(stderr, "Generate erofs image from DIRECTORY to FILE, and [options] are:\n");
> +	fprintf(stderr, " -h|--help print usage message then exit 0\n");

How about moving it to the last line with the following change?

	                "--help     display this help and exit"

and can we merge all fprintf into one line?


>  	fprintf(stderr, " -zX[,Y]   X=compressor (Y=compression level, optional)\n");
>  	fprintf(stderr, " -d#       set output message level to # (maximum 9)\n");
>  	fprintf(stderr, " -x#       set xattr tolerance to # (< 0, disable xattrs; default 2)\n");
> @@ -95,8 +103,10 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
>  {
>  	char *endptr;
>  	int opt, i;
> +	int option_index = 0;
>  
> -	while ((opt = getopt(argc, argv, "d:x:z:E:T:")) != -1) {
> +	while((opt = getopt_long(argc, argv, "d:z:E:T:h", long_options,

	while((opt = getopt_long(argc, argv, "d:z:E:T:", long_options,

> +				 &option_index)) != -1) {
>  		switch (opt) {
>  		case 'z':
>  			if (!optarg) {
> @@ -146,6 +156,11 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
>  			}
>  			break;
>  
> +		case 'h':

		case 1:

> +		case '?':

remove this line.
If you don't care, I can post a modified version here.

Thanks,
Gao Xiang

> +			usage();
> +			exit(0);
> +
>  		default: /* '?' */
>  			return -EINVAL;
>  		}
> -- 
> 2.17.1
> 

  reply index

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-21 18:19 Li Guifu
2019-10-22  2:50 ` Gao Xiang [this message]
2019-10-22  4:10   ` [PATCH v2] " Gao Xiang
2019-10-22 15:51     ` Li Guifu
2019-10-22 17:25       ` [PATCH v3] " Gao Xiang via Linux-erofs

Reply instructions:

You may reply publically 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=20191022025053.GA180717@architecture4 \
    --to=gaoxiang25@huawei.com \
    --cc=blucerlee@gmail.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=wylgf01@163.com \
    /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

Linux-EROFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-erofs/0 linux-erofs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-erofs linux-erofs/ https://lore.kernel.org/linux-erofs \
		linux-erofs@lists.ozlabs.org linux-erofs@ozlabs.org
	public-inbox-index linux-erofs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.ozlabs.lists.linux-erofs


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git