[lttng-dev] [PATCH] Add --list-options to each command

Mathieu Desnoyers compudj at krystal.dyndns.org
Tue Jan 24 09:44:31 EST 2012


* Simon Marchi (simon.marchi at polymtl.ca) wrote:
> Add a '--list-options' option to each command. This is intended to be
> used for programmable Bash completion.

This sounds like an excellent idea ! A few comments below,

> 
> I sent a similar patch at the end of last summer, but it seems that it
> has never been merged.
> 
> Signed-off-by: Simon Marchi <simon.marchi at polymtl.ca>
> ---
>  src/bin/lttng/commands/add_context.c      |    6 ++++++
>  src/bin/lttng/commands/calibrate.c        |    6 ++++++
>  src/bin/lttng/commands/create.c           |   11 +++++++++--
>  src/bin/lttng/commands/destroy.c          |    6 ++++++
>  src/bin/lttng/commands/disable_channels.c |    6 ++++++
>  src/bin/lttng/commands/disable_events.c   |    6 ++++++
>  src/bin/lttng/commands/enable_channels.c  |    5 +++++
>  src/bin/lttng/commands/enable_events.c    |    6 ++++++
>  src/bin/lttng/commands/list.c             |    6 ++++++
>  src/bin/lttng/commands/set_session.c      |    6 ++++++
>  src/bin/lttng/commands/start.c            |    6 ++++++
>  src/bin/lttng/commands/stop.c             |    6 ++++++
>  src/bin/lttng/commands/version.c          |    6 ++++++
>  src/bin/lttng/utils.c                     |   25 +++++++++++++++++++++++++
>  src/bin/lttng/utils.h                     |    3 +++
>  15 files changed, 108 insertions(+), 2 deletions(-)
> 
> diff --git a/src/bin/lttng/commands/add_context.c b/src/bin/lttng/commands/add_context.c
> index 260c300..761a732 100644
> --- a/src/bin/lttng/commands/add_context.c
> +++ b/src/bin/lttng/commands/add_context.c
> @@ -48,6 +48,7 @@ enum {
>  	OPT_HELP = 1,
>  	OPT_TYPE,
>  	OPT_USERSPACE,
> +	OPT_LIST_OPTIONS,
>  };
>  
>  static struct lttng_handle *handle;
> @@ -149,6 +150,7 @@ static struct poptOption long_options[] = {
>  	{"userspace",      'u', POPT_ARG_NONE, 0, OPT_USERSPACE, 0, 0},
>  #endif
>  	{"type",           't', POPT_ARG_STRING, &opt_type, OPT_TYPE, 0, 0},
> +	{"list-options",   '\0', POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},

If we look at the other options (in other files), 0 (instead of '\0')
seems to be used as second field. This would keep the style more
coherent. Can you change this across the whole patch and resubmit ?

[...]

e.g. here:
>  static struct lttng_handle *handle;
> @@ -70,6 +71,7 @@ static struct poptOption long_options[] = {
>  	{"num-subbuf",     0,   POPT_ARG_INT, 0, OPT_NUM_SUBBUF, 0, 0},
>  	{"switch-timer",   0,   POPT_ARG_INT, 0, OPT_SWITCH_TIMER, 0, 0},
>  	{"read-timer",     0,   POPT_ARG_INT, 0, OPT_READ_TIMER, 0, 0},
> +	{"list-options",   '\0', POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
>  	{0, 0, 0, 0, 0, 0, 0}
>  };

The rest looks fine!

Thanks,

Mathieu

-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com



More information about the lttng-dev mailing list