perf data: Correct -h output
There is currently only 1 'perf data' command, but supporting extra
commands was breaking the help output. Simplify for now so that the help
output is correct.
Before:
$ perf data -h
Usage: perf data [<common options>] <command> [<options>]
$ perf data
Usage:
perf data [<common options>] <command> [<options>]
Available commands:
convert - converts data file between formats
After:
$ perf data
Usage: perf data convert [<options>]
-f, --force don't complain, do it
-i, --input <file> input file name
-v, --verbose be more verbose
--all Convert all events
--to-ctf ... Convert to CTF format
--to-json ... Convert to JSON format
--tod Convert time to wall clock time
$ perf data -h
Usage: perf data convert [<options>]
-f, --force don't complain, do it
-i, --input <file> input file name
-v, --verbose be more verbose
--all Convert all events
--to-ctf ... Convert to CTF format
--to-json ... Convert to JSON format
--tod Convert time to wall clock time
Signed-off-by: Joshua Martinez <joshuamart@google.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lore.kernel.org/lkml/20210824205829.52822-1-irogers@google.com
Signed-off-by: Ian Rogers <irogers@google.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
cb5a2ebbf1
commit
760f5e77e6
@ -21,46 +21,21 @@ static struct data_cmd data_cmds[];
|
|||||||
#define for_each_cmd(cmd) \
|
#define for_each_cmd(cmd) \
|
||||||
for (cmd = data_cmds; cmd && cmd->name; cmd++)
|
for (cmd = data_cmds; cmd && cmd->name; cmd++)
|
||||||
|
|
||||||
static const struct option data_options[] = {
|
|
||||||
OPT_END()
|
|
||||||
};
|
|
||||||
|
|
||||||
static const char * const data_subcommands[] = { "convert", NULL };
|
static const char * const data_subcommands[] = { "convert", NULL };
|
||||||
|
|
||||||
static const char *data_usage[] = {
|
static const char *data_usage[] = {
|
||||||
"perf data [<common options>] <command> [<options>]",
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
static void print_usage(void)
|
|
||||||
{
|
|
||||||
struct data_cmd *cmd;
|
|
||||||
|
|
||||||
printf("Usage:\n");
|
|
||||||
printf("\t%s\n\n", data_usage[0]);
|
|
||||||
printf("\tAvailable commands:\n");
|
|
||||||
|
|
||||||
for_each_cmd(cmd) {
|
|
||||||
printf("\t %s\t- %s\n", cmd->name, cmd->summary);
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char * const data_convert_usage[] = {
|
|
||||||
"perf data convert [<options>]",
|
"perf data convert [<options>]",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
static int cmd_data_convert(int argc, const char **argv)
|
const char *to_json;
|
||||||
{
|
const char *to_ctf;
|
||||||
const char *to_json = NULL;
|
struct perf_data_convert_opts opts = {
|
||||||
const char *to_ctf = NULL;
|
.force = false,
|
||||||
struct perf_data_convert_opts opts = {
|
.all = false,
|
||||||
.force = false,
|
};
|
||||||
.all = false,
|
|
||||||
};
|
const struct option data_options[] = {
|
||||||
const struct option options[] = {
|
|
||||||
OPT_INCR('v', "verbose", &verbose, "be more verbose"),
|
OPT_INCR('v', "verbose", &verbose, "be more verbose"),
|
||||||
OPT_STRING('i', "input", &input_name, "file", "input file name"),
|
OPT_STRING('i', "input", &input_name, "file", "input file name"),
|
||||||
OPT_STRING(0, "to-json", &to_json, NULL, "Convert to JSON format"),
|
OPT_STRING(0, "to-json", &to_json, NULL, "Convert to JSON format"),
|
||||||
@ -73,10 +48,13 @@ static int cmd_data_convert(int argc, const char **argv)
|
|||||||
OPT_END()
|
OPT_END()
|
||||||
};
|
};
|
||||||
|
|
||||||
argc = parse_options(argc, argv, options,
|
static int cmd_data_convert(int argc, const char **argv)
|
||||||
data_convert_usage, 0);
|
{
|
||||||
|
|
||||||
|
argc = parse_options(argc, argv, data_options,
|
||||||
|
data_usage, 0);
|
||||||
if (argc) {
|
if (argc) {
|
||||||
usage_with_options(data_convert_usage, options);
|
usage_with_options(data_usage, data_options);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,14 +94,13 @@ int cmd_data(int argc, const char **argv)
|
|||||||
struct data_cmd *cmd;
|
struct data_cmd *cmd;
|
||||||
const char *cmdstr;
|
const char *cmdstr;
|
||||||
|
|
||||||
/* No command specified. */
|
|
||||||
if (argc < 2)
|
|
||||||
goto usage;
|
|
||||||
|
|
||||||
argc = parse_options_subcommand(argc, argv, data_options, data_subcommands, data_usage,
|
argc = parse_options_subcommand(argc, argv, data_options, data_subcommands, data_usage,
|
||||||
PARSE_OPT_STOP_AT_NON_OPTION);
|
PARSE_OPT_STOP_AT_NON_OPTION);
|
||||||
if (argc < 1)
|
|
||||||
goto usage;
|
if (!argc) {
|
||||||
|
usage_with_options(data_usage, data_options);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
cmdstr = argv[0];
|
cmdstr = argv[0];
|
||||||
|
|
||||||
@ -135,7 +112,6 @@ int cmd_data(int argc, const char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
pr_err("Unknown command: %s\n", cmdstr);
|
pr_err("Unknown command: %s\n", cmdstr);
|
||||||
usage:
|
usage_with_options(data_usage, data_options);
|
||||||
print_usage();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user