zmemtopo: Implement zsh and bash autocompletion

Add generation of shell autocompletion scripts.

Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Tested-by: Mete Durlu <meted@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Szabina Korbai <szkorbai@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Szabina Korbai
2026-03-06 15:25:28 +01:00
committed by Jan Höppner
parent 31d576a595
commit b444e71ee3
5 changed files with 73 additions and 36 deletions

2
.gitignore vendored
View File

@@ -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

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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;

49
zmemtopo/zmemtopo_cli.h Normal file
View File

@@ -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