mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Ramkumar Ramachandra <artagnon@gmail.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	David Ahern <dsahern@gmail.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: Re: [PATCH] perf kvm: introduce --list-cmds for use by scripts
Date: Wed, 5 Mar 2014 10:51:56 +0100	[thread overview]
Message-ID: <20140305095155.GA1835@krava.brq.redhat.com> (raw)
In-Reply-To: <1393896396-10427-1-git-send-email-artagnon@gmail.com>

On Mon, Mar 03, 2014 at 08:26:36PM -0500, Ramkumar Ramachandra wrote:
> Introduce
> 
>   $ perf kvm --list-cmds
> 
> to dump a raw list of commands for use by the completion script. In
> order to do this, introduce parse_options_subcommand() for handling
> subcommands as a special case in the parse-options machinery.

so this doesn't change the behaviour at all, right?

SNIP

>  
> -	argc = parse_options(argc, argv, kvm_options, kvm_usage,
> -			PARSE_OPT_STOP_AT_NON_OPTION);
> +	argc = parse_options_subcommand(argc, argv, kvm_options, kvm_subcommands, kvm_usage,
> +					PARSE_OPT_STOP_AT_NON_OPTION);
>  	if (!argc)
>  		usage_with_options(kvm_usage, kvm_options);
>  
> diff --git a/tools/perf/perf-completion.sh b/tools/perf/perf-completion.sh
> index 496e2ab..ae3a576 100644
> --- a/tools/perf/perf-completion.sh
> +++ b/tools/perf/perf-completion.sh
> @@ -123,7 +123,7 @@ __perf_main ()
>  		__perfcomp_colon "$evts" "$cur"
>  	# List subcommands for 'perf kvm'
>  	elif [[ $prev == "kvm" ]]; then
> -		subcmds="top record report diff buildid-list stat"
> +		subcmds=$($cmd $prev --list-cmds)

Do we want some generic approach here.. if we're
adding generic --list-cmds option anyway.. hm?

SNIP

> -int parse_options(int argc, const char **argv, const struct option *options,
> -		  const char * const usagestr[], int flags)
> +int parse_options_subcommand(int argc, const char **argv, const struct option *options,
> +			const char *const subcommands[], const char *usagestr[], int flags)
>  {
>  	struct parse_opt_ctx_t ctx;
>  
>  	perf_header__set_cmdline(argc, argv);
>  
> +	/* build usage string if it's not provided */
> +	if (subcommands && !usagestr[0]) {
> +		struct strbuf buf = STRBUF_INIT;
> +
> +		strbuf_addf(&buf, "perf %s [<options>] {", argv[0]);
> +		for (int i = 0; subcommands[i]; i++) {
> +			if (i)
> +				strbuf_addstr(&buf, "|");
> +			strbuf_addstr(&buf, subcommands[i]);
> +		}
> +		strbuf_addstr(&buf, "}");
> +
> +		usagestr[0] = strdup(buf.buf);
> +		strbuf_release(&buf);
> +	}

is above code ever used now?

jirka

  parent reply	other threads:[~2014-03-05  9:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-04  1:26 Ramkumar Ramachandra
2014-03-05  1:00 ` David Ahern
2014-03-05  9:51 ` Jiri Olsa [this message]
2014-03-05 16:25   ` Ramkumar Ramachandra
2014-03-13 15:52     ` Ramkumar Ramachandra
2014-03-14 13:01       ` Jiri Olsa
2014-03-18  8:30 ` [tip:perf/core] " tip-bot for Ramkumar Ramachandra
  -- strict thread matches above, loose matches on Subject: below --
2013-12-12 16:53 [PATCH 1/2] perf completion: complete 'perf kvm' David Ahern
2013-12-12 17:26 ` [PATCH] perf kvm: introduce --list-cmds for use by scripts Ramkumar Ramachandra
2013-12-13  4:32   ` David Ahern
2013-12-16 13:16   ` Arnaldo Carvalho de Melo

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=20140305095155.GA1835@krava.brq.redhat.com \
    --to=jolsa@redhat.com \
    --cc=acme@redhat.com \
    --cc=artagnon@gmail.com \
    --cc=dsahern@gmail.com \
    --cc=linux-kernel@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

Powered by JetHome