On Mon, Nov 04, 2019 at 02:33:02PM +0800, Anand Jain wrote:
> + case 'v':
> + bconf.verbose < 0 ? bconf.verbose = 1 : bconf.verbose++;
This code gets repeated and it's not IMO simple enough to be copy-pasted
around. Eg. bconf_be_verbose() and eventually bconf_be_quiet().
> + break;
> + case 'q':
> + bconf.verbose = 0;
> + break;
> default:
> fprintf(stderr, "Unknown global option: %s\n",
> argv[optind - 1]);
> --- a/common/help.h
> +++ b/common/help.h
> @@ -53,6 +53,17 @@
> "-t|--tbytes show sizes in TiB, or TB with --si"
>
> /*
> + * Global verbose option for the sub-commands
> + */
> +#define HELPINFO_GLOBAL_OPTIONS_HEADER \
> + "", \
> + "Global options:"
> +#define HELPINFO_INSERT_VERBOSE \
> + "-v|--verbose show verbose output"
increase output verbosity
> +#define HELPINFO_INSERT_QUIET \
> + "-q|--quiet run the command quietly"
print only errors
> +
> +/*
> * Special marker in the help strings that will preemptively insert the global
> * options and then continue with the following text that possibly follows
> * after the regular options
> --- a/common/utils.h
> +++ b/common/utils.h
> @@ -122,6 +122,9 @@ void print_all_devices(struct list_head *devices);
> */
> struct btrfs_config {
> unsigned int output_format;
> +
> + /* -1:unset 0:quiet >0:verbose */
Instead of the constants, please add some defines for the unset and
default states. Maybe also for quiet.
> + int verbose;
> };
> extern struct btrfs_config bconf;