mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
lscss: Implement zsh and bash autocompletion
Add generation of shell autocompletion scripts. Modify --devtype flag description to make it compatible with zsh autocompletion. Acked-by: Steffen Eiden <seiden@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:
committed by
Jan Höppner
parent
35d5f41232
commit
e9ee658492
2
.gitignore
vendored
2
.gitignore
vendored
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
16
zconf/css/autocompletion_generator_host.c
Normal file
16
zconf/css/autocompletion_generator_host.c
Normal file
@@ -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;
|
||||
}
|
||||
@@ -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
|
||||
|
||||
86
zconf/css/lscss_cli.h
Normal file
86
zconf/css/lscss_cli.h
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user