diff --git a/.gitignore b/.gitignore index 2f9352d9..8604ba24 100644 --- a/.gitignore +++ b/.gitignore @@ -128,6 +128,8 @@ zconf/chp/chpstat/chpstat zconf/chp/chpstat/_chpstat zconf/chp/chpstat/chpstat.bash zconf/css/lscss +zconf/css/_lscss +zconf/css/lscss.bash zconf/qeth/lsqeth zconf/scm/lsscm zconf/zcrypt/chzcrypt diff --git a/zconf/css/Makefile b/zconf/css/Makefile index 2a36820f..20a0f15d 100644 --- a/zconf/css/Makefile +++ b/zconf/css/Makefile @@ -1,6 +1,11 @@ # Common definitions include ../../common.mak +zsh-completions = _lscss +bash-completions = lscss.bash + +include ../../common_autocomp.mak + libs = $(rootdir)/libccw/libccw.a \ $(rootdir)/libutil/libutil.a diff --git a/zconf/css/autocompletion_generator_host.c b/zconf/css/autocompletion_generator_host.c new file mode 100644 index 00000000..30113cc7 --- /dev/null +++ b/zconf/css/autocompletion_generator_host.c @@ -0,0 +1,16 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright IBM Corp. + */ + +#include "lib/util_autocomp.h" + +#include "lscss_cli.h" + +int main(void) +{ + generate_autocomp(opt_vec, "lscss"); + + return 0; +} diff --git a/zconf/css/lscss.c b/zconf/css/lscss.c index cb0b7cb9..0c15b9dc 100644 --- a/zconf/css/lscss.c +++ b/zconf/css/lscss.c @@ -21,18 +21,9 @@ #include "lib/util_rec.h" #include "lib/util_scandir.h" +#include "lscss_cli.h" #include "misc.h" -/* - * Numbers for lscss command options that do not have a short form - */ -#define OPT_AVAIL 256 /* --avail */ -#define OPT_VPM 257 /* --vpm */ -#define OPT_IO 258 /* --io */ -#define OPT_CHSC 259 /* --chsc */ -#define OPT_EADM 260 /* --eadm */ -#define OPT_VFIO 261 /* --vfio */ - /* Bus_id format for subchannel or device id */ #define ID_FORMAT "^[[:xdigit:]]{1,2}[.][[:xdigit:]][.][[:xdigit:]]{4}$" /* UUID format */ @@ -109,70 +100,6 @@ static const struct util_prg prg = { } }; -/* - * Command line options - */ -static struct util_opt opt_vec[] = { - UTIL_OPT_SECTION("OPTIONS"), - { - .option = { "short", no_argument, NULL, 's'}, - .desc = "Shorten IDs by removing leading \"0.0.\" " - "Note: only IDs beginning with \"0.0.\" " - "will be displayed in this case.", - }, - { - .option = { "devtype", required_argument, NULL, 't'}, - .argument = "TYPE,..", - .desc = "For IO subchannels, limit output to devices of " - "the given TYPE (DEVTYPE[/MODEL])", - }, - { - .option = { "devrange", no_argument, NULL, 'd'}, - .desc = "Indicate that RANGE refers to device identifiers", - }, - { - .option = { "avail", no_argument, NULL, OPT_AVAIL}, - .desc = "Show availability attribute of IO devices", - .flags = UTIL_OPT_FLAG_NOSHORT, - }, - { - .option = { "vpm", no_argument, NULL, OPT_VPM}, - .desc = "Show verified path mask", - .flags = UTIL_OPT_FLAG_NOSHORT, - }, - { - .option = { "uppercase", no_argument, NULL, 'u'}, - .desc = "Print values using uppercase", - }, - { - .option = { "io", no_argument, NULL, OPT_IO}, - .desc = "Show IO subchannels (default)", - .flags = UTIL_OPT_FLAG_NOSHORT, - }, - { - .option = { "chsc", no_argument, NULL, OPT_CHSC}, - .desc = "Show CHSC subchannels", - .flags = UTIL_OPT_FLAG_NOSHORT, - }, - { - .option = { "eadm", no_argument, NULL, OPT_EADM}, - .desc = "Show EADM subchannels", - .flags = UTIL_OPT_FLAG_NOSHORT, - }, - { - .option = { "vfio", no_argument, NULL, OPT_VFIO}, - .desc = "Show VFIO subchannel information", - .flags = UTIL_OPT_FLAG_NOSHORT, - }, - { - .option = { "all", no_argument, NULL, 'a'}, - .desc = "Show subchannels of all types", - }, - UTIL_OPT_HELP, - UTIL_OPT_VERSION, - UTIL_OPT_END -}; - /* * Add new subchannel or device range to the ranges list for further output * limitation diff --git a/zconf/css/lscss_cli.h b/zconf/css/lscss_cli.h new file mode 100644 index 00000000..d6545374 --- /dev/null +++ b/zconf/css/lscss_cli.h @@ -0,0 +1,86 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright IBM Corp. + */ + +#ifndef LSCSS_CLI_H +#define LSCSS_CLI_H + +#include "lib/util_opt.h" + +/* + * Numbers for lscss command options that do not have a short form + */ +#define OPT_AVAIL 256 /* --avail */ +#define OPT_VPM 257 /* --vpm */ +#define OPT_IO 258 /* --io */ +#define OPT_CHSC 259 /* --chsc */ +#define OPT_EADM 260 /* --eadm */ +#define OPT_VFIO 261 /* --vfio */ + +/* + * Command line options + */ +static struct util_opt opt_vec[] = { + UTIL_OPT_SECTION("OPTIONS"), + { + .option = { "short", no_argument, NULL, 's'}, + .desc = "Shorten IDs by removing leading '0.0.' " + "Note: only IDs beginning with '0.0.' " + "will be displayed in this case.", + }, + { + .option = { "devtype", required_argument, NULL, 't'}, + .argument = "TYPE (DEVTYPE[/MODEL])", + .desc = "For IO subchannels, limit output to devices of " + "the given type", + }, + { + .option = { "devrange", no_argument, NULL, 'd'}, + .desc = "Indicate that RANGE refers to device identifiers", + }, + { + .option = { "avail", no_argument, NULL, OPT_AVAIL}, + .desc = "Show availability attribute of IO devices", + .flags = UTIL_OPT_FLAG_NOSHORT, + }, + { + .option = { "vpm", no_argument, NULL, OPT_VPM}, + .desc = "Show verified path mask", + .flags = UTIL_OPT_FLAG_NOSHORT, + }, + { + .option = { "uppercase", no_argument, NULL, 'u'}, + .desc = "Print values using uppercase", + }, + { + .option = { "io", no_argument, NULL, OPT_IO}, + .desc = "Show IO subchannels (default)", + .flags = UTIL_OPT_FLAG_NOSHORT, + }, + { + .option = { "chsc", no_argument, NULL, OPT_CHSC}, + .desc = "Show CHSC subchannels", + .flags = UTIL_OPT_FLAG_NOSHORT, + }, + { + .option = { "eadm", no_argument, NULL, OPT_EADM}, + .desc = "Show EADM subchannels", + .flags = UTIL_OPT_FLAG_NOSHORT, + }, + { + .option = { "vfio", no_argument, NULL, OPT_VFIO}, + .desc = "Show VFIO subchannel information", + .flags = UTIL_OPT_FLAG_NOSHORT, + }, + { + .option = { "all", no_argument, NULL, 'a'}, + .desc = "Show subchannels of all types", + }, + UTIL_OPT_HELP, + UTIL_OPT_VERSION, + UTIL_OPT_END +}; + +#endif