mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
chp: Implement zsh and bash autocompletion
Add generation of shell autocompletion scripts to chchp and lschp. 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
b444e71ee3
commit
260a0a2428
4
.gitignore
vendored
4
.gitignore
vendored
@@ -119,7 +119,11 @@ vmcp/_vmcp
|
||||
vmcp/vmcp.bash
|
||||
vmur/vmur
|
||||
zconf/chp/chchp
|
||||
zconf/chp/_chchp
|
||||
zconf/chp/chchp.bash
|
||||
zconf/chp/lschp
|
||||
zconf/chp/_lschp
|
||||
zconf/chp/lschp.bash
|
||||
zconf/chp/chpstat/chpstat
|
||||
zconf/css/lscss
|
||||
zconf/qeth/lsqeth
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
include ../../common.mak
|
||||
|
||||
zsh-completions := _chchp _lschp
|
||||
bash-completions := chchp.bash lschp.bash
|
||||
|
||||
include ../../common_autocomp.mak
|
||||
|
||||
all: chchp lschp chpstat
|
||||
$(MAKE) -C chpstat all
|
||||
|
||||
|
||||
18
zconf/chp/autocompletion_generator_host.c
Normal file
18
zconf/chp/autocompletion_generator_host.c
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Copyright IBM Corp.
|
||||
*/
|
||||
|
||||
#include "lib/util_autocomp.h"
|
||||
|
||||
#include "chchp_cli.h"
|
||||
#include "lschp_cli.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
generate_autocomp(chchp_opt_vec, "chchp");
|
||||
generate_autocomp(lschp_opt_vec, "lschp");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -25,6 +25,8 @@
|
||||
#include "lib/util_prg.h"
|
||||
#include "lib/zt_common.h"
|
||||
|
||||
#include "chchp_cli.h"
|
||||
|
||||
#define CIO_SETTLE "/proc/cio_settle"
|
||||
#define MAX_CHPID_CSS 255
|
||||
#define MAX_CHPID_ID 255
|
||||
@@ -63,33 +65,6 @@ const struct util_prg prg = {
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* Configuration of command line options
|
||||
*/
|
||||
static struct util_opt opt_vec[] = {
|
||||
{
|
||||
.option = { "vary", required_argument, NULL, 'v'},
|
||||
.argument = "VALUE",
|
||||
.desc = "Logically vary channel-path to VALUE (1=on, 0=off)",
|
||||
},
|
||||
{
|
||||
.option = { "configure", required_argument, NULL, 'c'},
|
||||
.argument = "VALUE",
|
||||
.desc = "Configure channel-path to VALUE (1=on, 0=standby)",
|
||||
},
|
||||
{
|
||||
.option = { "attribute", required_argument, NULL, 'a'},
|
||||
.argument = "KEY=VALUE",
|
||||
.desc = "Set channel-path attribute KEY to VALUE",
|
||||
},
|
||||
UTIL_OPT_HELP,
|
||||
{
|
||||
.option = { "version", 0, NULL, 'V'},
|
||||
.desc = "Print version information, then exit",
|
||||
},
|
||||
UTIL_OPT_END
|
||||
};
|
||||
|
||||
/*
|
||||
* Write and check attribute value
|
||||
*/
|
||||
@@ -370,7 +345,7 @@ int main(int argc, char *argv[])
|
||||
int c, i;
|
||||
|
||||
util_prg_init(&prg);
|
||||
util_opt_init(opt_vec, NULL);
|
||||
util_opt_init(chchp_opt_vec, NULL);
|
||||
while (1) {
|
||||
c = util_opt_getopt_long(argc, argv);
|
||||
if (c == -1)
|
||||
|
||||
39
zconf/chp/chchp_cli.h
Normal file
39
zconf/chp/chchp_cli.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Copyright IBM Corp.
|
||||
*/
|
||||
|
||||
#ifndef CHCHP_CLI_H
|
||||
#define CHCHP_CLI_H
|
||||
|
||||
#include "lib/util_opt.h"
|
||||
|
||||
/*
|
||||
* Configuration of command line options
|
||||
*/
|
||||
static struct util_opt chchp_opt_vec[] = {
|
||||
{
|
||||
.option = { "vary", required_argument, NULL, 'v'},
|
||||
.argument = "VALUE",
|
||||
.desc = "Logically vary channel-path to VALUE (1=on, 0=off)",
|
||||
},
|
||||
{
|
||||
.option = { "configure", required_argument, NULL, 'c'},
|
||||
.argument = "VALUE",
|
||||
.desc = "Configure channel-path to VALUE (1=on, 0=standby)",
|
||||
},
|
||||
{
|
||||
.option = { "attribute", required_argument, NULL, 'a'},
|
||||
.argument = "KEY=VALUE",
|
||||
.desc = "Set channel-path attribute KEY to VALUE",
|
||||
},
|
||||
UTIL_OPT_HELP,
|
||||
{
|
||||
.option = { "version", 0, NULL, 'V'},
|
||||
.desc = "Print version information, then exit",
|
||||
},
|
||||
UTIL_OPT_END
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -24,6 +24,8 @@
|
||||
#include "lib/util_scandir.h"
|
||||
#include "lib/zt_common.h"
|
||||
|
||||
#include "lschp_cli.h"
|
||||
|
||||
#define CHP_SHARED "shared"
|
||||
#define CHP_STATE "vary"
|
||||
#define CHP_PCHID "pchid"
|
||||
@@ -35,8 +37,6 @@
|
||||
static enum util_fmt_t fmt;
|
||||
static bool fmt_specified;
|
||||
|
||||
#define OPT_FORMAT 262 /* --format */
|
||||
|
||||
/*
|
||||
* Program configuration
|
||||
*/
|
||||
@@ -52,21 +52,6 @@ static const struct util_prg prg = {
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* Configuration of command line options
|
||||
*/
|
||||
static struct util_opt opt_vec[] = {
|
||||
UTIL_OPT_HELP,
|
||||
UTIL_OPT_VERSION,
|
||||
{
|
||||
.option = { "format", required_argument, NULL, OPT_FORMAT},
|
||||
.argument = "FORMAT",
|
||||
.desc = "Output format (" FMT_TYPE_NAMES ")",
|
||||
.flags = UTIL_OPT_FLAG_NOSHORT,
|
||||
},
|
||||
UTIL_OPT_END
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the "--format" option
|
||||
*
|
||||
@@ -321,7 +306,7 @@ int main(int argc, char *argv[])
|
||||
int c;
|
||||
|
||||
util_prg_init(&prg);
|
||||
util_opt_init(opt_vec, NULL);
|
||||
util_opt_init(lschp_opt_vec, NULL);
|
||||
|
||||
while (1) {
|
||||
c = util_opt_getopt_long(argc, argv);
|
||||
|
||||
30
zconf/chp/lschp_cli.h
Normal file
30
zconf/chp/lschp_cli.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Copyright IBM Corp.
|
||||
*/
|
||||
|
||||
#ifndef LSCHP_CLI_H
|
||||
#define LSCHP_CLI_H
|
||||
|
||||
#include "lib/util_fmt.h"
|
||||
#include "lib/util_opt.h"
|
||||
|
||||
#define OPT_FORMAT 262 /* --format */
|
||||
|
||||
/*
|
||||
* Configuration of command line options
|
||||
*/
|
||||
static struct util_opt lschp_opt_vec[] = {
|
||||
UTIL_OPT_HELP,
|
||||
UTIL_OPT_VERSION,
|
||||
{
|
||||
.option = { "format", required_argument, NULL, OPT_FORMAT},
|
||||
.argument = "FORMAT",
|
||||
.desc = "Output format (" FMT_TYPE_NAMES ")",
|
||||
.flags = UTIL_OPT_FLAG_NOSHORT,
|
||||
},
|
||||
UTIL_OPT_END
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user