From f70991ab1e1a0e89dcfecca164d6e4f6e9ee50ac Mon Sep 17 00:00:00 2001 From: Szabina Korbai Date: Fri, 6 Mar 2026 16:23:39 +0100 Subject: [PATCH] lsqeth: Implement zsh and bash autocompletion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add generation of shell autocompletion scripts. Acked-by: Steffen Eiden Reviewed-by: Jan Höppner Signed-off-by: Szabina Korbai Signed-off-by: Jan Höppner --- .gitignore | 2 ++ zconf/qeth/Makefile | 5 +++++ zconf/qeth/autocompletion_generator_host.c | 16 +++++++++++++ zconf/qeth/lsqeth.c | 15 +------------ zconf/qeth/lsqeth_cli.h | 26 ++++++++++++++++++++++ 5 files changed, 50 insertions(+), 14 deletions(-) create mode 100644 zconf/qeth/autocompletion_generator_host.c create mode 100644 zconf/qeth/lsqeth_cli.h diff --git a/.gitignore b/.gitignore index 8604ba24..65f46a51 100644 --- a/.gitignore +++ b/.gitignore @@ -131,6 +131,8 @@ zconf/css/lscss zconf/css/_lscss zconf/css/lscss.bash zconf/qeth/lsqeth +zconf/qeth/_lsqeth +zconf/qeth/lsqeth.bash zconf/scm/lsscm zconf/zcrypt/chzcrypt zconf/zcrypt/lszcrypt diff --git a/zconf/qeth/Makefile b/zconf/qeth/Makefile index 43716a33..3f76e697 100644 --- a/zconf/qeth/Makefile +++ b/zconf/qeth/Makefile @@ -1,5 +1,10 @@ include ../../common.mak +zsh-completions = _lsqeth +bash-completions = lsqeth.bash + +include ../../common_autocomp.mak + all: lsqeth libs = $(rootdir)/libvmcp/libvmcp.a $(rootdir)/libutil/libutil.a diff --git a/zconf/qeth/autocompletion_generator_host.c b/zconf/qeth/autocompletion_generator_host.c new file mode 100644 index 00000000..cb3da614 --- /dev/null +++ b/zconf/qeth/autocompletion_generator_host.c @@ -0,0 +1,16 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright IBM Corp. + */ + +#include "lib/util_autocomp.h" + +#include "lsqeth_cli.h" + +int main(void) +{ + generate_autocomp(opt_vec, "lsqeth"); + + return 0; +} diff --git a/zconf/qeth/lsqeth.c b/zconf/qeth/lsqeth.c index 164f0586..5f60dd7d 100644 --- a/zconf/qeth/lsqeth.c +++ b/zconf/qeth/lsqeth.c @@ -39,6 +39,7 @@ #include "lib/zt_common.h" #include "lib/vmcp.h" +#include "lsqeth_cli.h" #include "misc.h" #define ID_FORMAT "^[[:xdigit:]]{1,2}[.][[:xdigit:]][.][[:xdigit:]]{4}$" @@ -70,20 +71,6 @@ const struct util_prg prg = { } }; -/* - * Command line options - */ -static struct util_opt opt_vec[] = { - UTIL_OPT_SECTION("OPTIONS"), - { - .option = { "proc", no_argument, NULL, 'p'}, - .desc = "List all devices in the former /proc/qeth format" - }, - UTIL_OPT_HELP, - UTIL_OPT_VERSION, - UTIL_OPT_END -}; - /* * Exchange content of field value via simple translation map * diff --git a/zconf/qeth/lsqeth_cli.h b/zconf/qeth/lsqeth_cli.h new file mode 100644 index 00000000..8d10801e --- /dev/null +++ b/zconf/qeth/lsqeth_cli.h @@ -0,0 +1,26 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright IBM Corp. + */ + +#ifndef LSQETH_CLI_H +#define LSQETH_CLI_H + +#include "lib/util_opt.h" + +/* + * Command line options + */ +static struct util_opt opt_vec[] = { + UTIL_OPT_SECTION("OPTIONS"), + { + .option = { "proc", no_argument, NULL, 'p'}, + .desc = "List all devices in the former /proc/qeth format" + }, + UTIL_OPT_HELP, + UTIL_OPT_VERSION, + UTIL_OPT_END +}; + +#endif