diff --git a/.gitignore b/.gitignore index 53401a52..6eaa2e5f 100644 --- a/.gitignore +++ b/.gitignore @@ -167,6 +167,8 @@ zkey/kmip/zkey-kmip.so zkey/zkey zkey/zkey-cryptsetup zmemtopo/zmemtopo +zmemtopo/_zmemtopo +zmemtopo/zmemtopo.bash zpcictl/zpcictl zpcictl/_zpcictl zpcictl/zpcictl.bash diff --git a/zmemtopo/Makefile b/zmemtopo/Makefile index 199e534d..3ad9e950 100644 --- a/zmemtopo/Makefile +++ b/zmemtopo/Makefile @@ -6,6 +6,11 @@ # include ../common.mak +zsh-completions = _zmemtopo +bash-completions = zmemtopo.bash + +include ../common_autocomp.mak + libs = $(rootdir)/libutil/libutil.a all: zmemtopo diff --git a/zmemtopo/autocompletion_generator_host.c b/zmemtopo/autocompletion_generator_host.c new file mode 100644 index 00000000..8b86a3eb --- /dev/null +++ b/zmemtopo/autocompletion_generator_host.c @@ -0,0 +1,16 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright IBM Corp. + */ + +#include "lib/util_autocomp.h" + +#include "zmemtopo_cli.h" + +int main(void) +{ + generate_autocomp(opt_vec, "zmemtopo"); + + return 0; +} diff --git a/zmemtopo/zmemtopo.c b/zmemtopo/zmemtopo.c index cbdff736..1f51caeb 100644 --- a/zmemtopo/zmemtopo.c +++ b/zmemtopo/zmemtopo.c @@ -23,8 +23,7 @@ #include "lib/util_prg.h" #include "zmemtopo.h" - -#define OPT_FORMAT 256 +#include "zmemtopo_cli.h" static const struct util_prg prg = { .desc = "Display CEC memory topology of allocated memory increments.", @@ -38,40 +37,6 @@ static const struct util_prg prg = { } }; -static struct util_opt opt_vec[] = { - UTIL_OPT_SECTION("OUTPUT FORMAT OPTIONS"), - { - .option = { "level", required_argument, NULL, 'l' }, - .argument = "NESTING_LEVEL", - .desc = "Set the topology display depth to NESTING_LEVEL" - }, { - .option = { "format", required_argument, NULL, OPT_FORMAT }, - .argument = "FORMAT", - .flags = UTIL_OPT_FLAG_NOSHORT, - .desc = "List data in specified FORMAT (" FMT_TYPE_NAMES ")", - }, { - .option = { "full", no_argument, NULL, 'f' }, - .desc = "Display tree view with padded elements" - }, { - .option = { "reverse", no_argument, NULL, 'r' }, - .desc = "Reverse tree view hierarchy direction" - }, { - .option = { "table", no_argument, NULL, 't' }, - .desc = "Use table view to display topology" - }, { - .option = { "sort", required_argument, NULL, 's' }, - .argument = "FIELD", - .desc = "Sort view by FIELD (nr, lpar, size)" - }, { - .option = { "ascii", no_argument, NULL, 'i' }, - .desc = "Use only ASCII characters", - }, - UTIL_OPT_SECTION("GENERAL OPTIONS"), - UTIL_OPT_HELP, - UTIL_OPT_VERSION, - UTIL_OPT_END -}; - static struct zmemtopo_globals { unsigned int nesting_level; unsigned int max_level; diff --git a/zmemtopo/zmemtopo_cli.h b/zmemtopo/zmemtopo_cli.h new file mode 100644 index 00000000..6b5c4e6d --- /dev/null +++ b/zmemtopo/zmemtopo_cli.h @@ -0,0 +1,49 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright IBM Corp. + */ + +#ifndef ZMEMTOPO_CLI_H +#define ZMEMTOPO_CLI_H + +#include "lib/util_fmt.h" +#include "lib/util_opt.h" + +#define OPT_FORMAT 256 + +static struct util_opt opt_vec[] = { + UTIL_OPT_SECTION("OUTPUT FORMAT OPTIONS"), + { + .option = { "level", required_argument, NULL, 'l' }, + .argument = "NESTING_LEVEL", + .desc = "Set the topology display depth to NESTING_LEVEL" + }, { + .option = { "format", required_argument, NULL, OPT_FORMAT }, + .argument = "FORMAT", + .flags = UTIL_OPT_FLAG_NOSHORT, + .desc = "List data in specified FORMAT (" FMT_TYPE_NAMES ")", + }, { + .option = { "full", no_argument, NULL, 'f' }, + .desc = "Display tree view with padded elements" + }, { + .option = { "reverse", no_argument, NULL, 'r' }, + .desc = "Reverse tree view hierarchy direction" + }, { + .option = { "table", no_argument, NULL, 't' }, + .desc = "Use table view to display topology" + }, { + .option = { "sort", required_argument, NULL, 's' }, + .argument = "FIELD", + .desc = "Sort view by FIELD (nr, lpar, size)" + }, { + .option = { "ascii", no_argument, NULL, 'i' }, + .desc = "Use only ASCII characters", + }, + UTIL_OPT_SECTION("GENERAL OPTIONS"), + UTIL_OPT_HELP, + UTIL_OPT_VERSION, + UTIL_OPT_END +}; + +#endif