mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
chpstat: Implement zsh and bash autocompletion
Add generation of shell autocompletion scripts. 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
260a0a2428
commit
35d5f41232
2
.gitignore
vendored
2
.gitignore
vendored
@@ -125,6 +125,8 @@ zconf/chp/lschp
|
||||
zconf/chp/_lschp
|
||||
zconf/chp/lschp.bash
|
||||
zconf/chp/chpstat/chpstat
|
||||
zconf/chp/chpstat/_chpstat
|
||||
zconf/chp/chpstat/chpstat.bash
|
||||
zconf/css/lscss
|
||||
zconf/qeth/lsqeth
|
||||
zconf/scm/lsscm
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
include ../../../common.mak
|
||||
|
||||
zsh-completions = _chpstat
|
||||
bash-completions = chpstat.bash
|
||||
|
||||
include ../../../common_autocomp.mak
|
||||
|
||||
all: chpstat
|
||||
|
||||
libs = $(rootdir)/libutil/libutil.a
|
||||
|
||||
16
zconf/chp/chpstat/autocompletion_generator_host.c
Normal file
16
zconf/chp/chpstat/autocompletion_generator_host.c
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Copyright IBM Corp.
|
||||
*/
|
||||
|
||||
#include "lib/util_autocomp.h"
|
||||
|
||||
#include "chpstat_cli.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
generate_autocomp(opt_vec, "chpstat");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -22,11 +22,6 @@
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "cmg.h"
|
||||
#include "column.h"
|
||||
#include "key.h"
|
||||
#include "misc.h"
|
||||
|
||||
#include "lib/util_base.h"
|
||||
#include "lib/util_file.h"
|
||||
#include "lib/util_fmt.h"
|
||||
@@ -37,6 +32,12 @@
|
||||
#include "lib/util_rec.h"
|
||||
#include "lib/zt_common.h"
|
||||
|
||||
#include "chpstat_cli.h"
|
||||
#include "cmg.h"
|
||||
#include "column.h"
|
||||
#include "key.h"
|
||||
#include "misc.h"
|
||||
|
||||
/* Output format API level. */
|
||||
#define API_LEVEL 1
|
||||
|
||||
@@ -99,29 +100,6 @@ static const struct util_prg prg = {
|
||||
.args = "[CHPIDS] [ACTIONS]",
|
||||
};
|
||||
|
||||
enum {
|
||||
OPT_STATUS = 's',
|
||||
OPT_ENABLE = 'e',
|
||||
OPT_DISABLE = 'd',
|
||||
OPT_LIST_COLUMNS = 'l',
|
||||
OPT_LIST_KEYS = 'L',
|
||||
OPT_ITERATIONS = 'n',
|
||||
OPT_INTERVAL = 'i',
|
||||
OPT_COLUMNS = 'c',
|
||||
OPT_KEYS = 'k',
|
||||
OPT_ALL = 'a',
|
||||
/* Options without short version below. */
|
||||
OPT_FORMAT = 0x80, /* First non-printable character. */
|
||||
OPT_CHARS,
|
||||
OPT_UTIL,
|
||||
OPT_METRICS,
|
||||
OPT_CMG,
|
||||
OPT_SCALE,
|
||||
OPT_NO_ANSI,
|
||||
OPT_NO_PREFIX,
|
||||
OPT_DEBUG,
|
||||
};
|
||||
|
||||
enum command_t {
|
||||
CMD_ENABLE = OPT_ENABLE,
|
||||
CMD_DISABLE = OPT_DISABLE,
|
||||
@@ -132,118 +110,6 @@ enum command_t {
|
||||
CMD_LIST,
|
||||
};
|
||||
|
||||
/*
|
||||
* Configuration of command line options
|
||||
*/
|
||||
static struct util_opt opt_vec[] = {
|
||||
{
|
||||
.desc = "ACTIONS",
|
||||
.flags = UTIL_OPT_FLAG_SECTION,
|
||||
},
|
||||
{
|
||||
.option = { "status", no_argument, NULL, OPT_STATUS },
|
||||
.desc = "Show channel-path statistics status",
|
||||
},
|
||||
{
|
||||
.option = { "enable", no_argument, NULL, OPT_ENABLE },
|
||||
.desc = "Enable channel-path statistics",
|
||||
},
|
||||
{
|
||||
.option = { "disable", no_argument, NULL, OPT_DISABLE },
|
||||
.desc = "Disable channel-path statistics",
|
||||
},
|
||||
{
|
||||
.option = { "list-columns", no_argument, NULL,
|
||||
OPT_LIST_COLUMNS},
|
||||
.desc = "List available table columns",
|
||||
},
|
||||
{
|
||||
.option = { "list-keys", no_argument, NULL, OPT_LIST_KEYS},
|
||||
.desc = "List available data keys",
|
||||
},
|
||||
UTIL_OPT_HELP,
|
||||
UTIL_OPT_VERSION,
|
||||
{
|
||||
.desc = "OPTIONS",
|
||||
.flags = UTIL_OPT_FLAG_SECTION,
|
||||
},
|
||||
{
|
||||
.option = { "iterations", required_argument, NULL,
|
||||
OPT_ITERATIONS },
|
||||
.argument = "NUM",
|
||||
.desc = "Display NUM reports before ending (0 for no end)",
|
||||
},
|
||||
{
|
||||
.option = { "interval", required_argument, NULL,
|
||||
OPT_INTERVAL },
|
||||
.argument = "NUM",
|
||||
.desc = "Pause NUM seconds between display",
|
||||
},
|
||||
{
|
||||
.option = { "columns", required_argument, NULL, OPT_COLUMNS },
|
||||
.argument = "COL,..",
|
||||
.desc = "Show only specified columns in table output",
|
||||
},
|
||||
{
|
||||
.option = { "keys", required_argument, NULL, OPT_KEYS },
|
||||
.argument = "KEY,..",
|
||||
.desc = "Show only data for specified keys in list output",
|
||||
},
|
||||
{
|
||||
.option = { "all", no_argument, NULL, OPT_ALL },
|
||||
.desc = "Show all table columns and key data",
|
||||
},
|
||||
{
|
||||
.option = { "scale", required_argument, NULL, OPT_SCALE },
|
||||
.argument = "UNIT",
|
||||
.flags = UTIL_OPT_FLAG_NOSHORT,
|
||||
.desc = "Scale BPS values by UNIT (number, suffix or auto)",
|
||||
},
|
||||
{
|
||||
.option = { "cmg", required_argument, NULL, OPT_CMG },
|
||||
.argument = "CMG,..",
|
||||
.flags = UTIL_OPT_FLAG_NOSHORT,
|
||||
.desc = "Show data for specified CMGs only",
|
||||
},
|
||||
{
|
||||
.option = { "format", required_argument, NULL, OPT_FORMAT },
|
||||
.argument = "FORMAT",
|
||||
.flags = UTIL_OPT_FLAG_NOSHORT,
|
||||
.desc = "List data in specified FORMAT (" FMT_TYPE_NAMES ")",
|
||||
},
|
||||
{
|
||||
.option = { "chars", no_argument, NULL, OPT_CHARS },
|
||||
.flags = UTIL_OPT_FLAG_NOSHORT,
|
||||
.desc = "List channel-path measurement characteristics",
|
||||
},
|
||||
{
|
||||
.option = { "util", no_argument, NULL, OPT_UTIL },
|
||||
.flags = UTIL_OPT_FLAG_NOSHORT,
|
||||
.desc = "List unprocessed utilization data",
|
||||
},
|
||||
{
|
||||
.option = { "metrics", no_argument, NULL, OPT_METRICS },
|
||||
.flags = UTIL_OPT_FLAG_NOSHORT,
|
||||
.desc = "List performance metrics",
|
||||
},
|
||||
{
|
||||
.option = { "no-ansi", no_argument, NULL, OPT_NO_ANSI },
|
||||
.flags = UTIL_OPT_FLAG_NOSHORT,
|
||||
.desc = "Do not use ANSI terminal codes in output",
|
||||
},
|
||||
{
|
||||
.option = { "no-prefix", no_argument, NULL, OPT_NO_PREFIX },
|
||||
.flags = UTIL_OPT_FLAG_NOSHORT,
|
||||
.desc = "Hide key prefix in pairs output format",
|
||||
},
|
||||
{
|
||||
.option = { "debug", no_argument, NULL, OPT_DEBUG },
|
||||
.flags = UTIL_OPT_FLAG_NOSHORT,
|
||||
.desc = "Print debugging information",
|
||||
},
|
||||
UTIL_OPT_END
|
||||
};
|
||||
|
||||
/* Settings from command line options. */
|
||||
static struct {
|
||||
bool cmd_specified;
|
||||
|
||||
148
zconf/chp/chpstat/chpstat_cli.h
Normal file
148
zconf/chp/chpstat/chpstat_cli.h
Normal file
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Copyright IBM Corp.
|
||||
*/
|
||||
|
||||
#ifndef CHPSTAT_H
|
||||
#define CHPSTAT_H
|
||||
|
||||
#include "lib/util_fmt.h"
|
||||
#include "lib/util_opt.h"
|
||||
|
||||
enum {
|
||||
OPT_STATUS = 's',
|
||||
OPT_ENABLE = 'e',
|
||||
OPT_DISABLE = 'd',
|
||||
OPT_LIST_COLUMNS = 'l',
|
||||
OPT_LIST_KEYS = 'L',
|
||||
OPT_ITERATIONS = 'n',
|
||||
OPT_INTERVAL = 'i',
|
||||
OPT_COLUMNS = 'c',
|
||||
OPT_KEYS = 'k',
|
||||
OPT_ALL = 'a',
|
||||
/* Options without short version below. */
|
||||
OPT_FORMAT = 0x80, /* First non-printable character. */
|
||||
OPT_CHARS,
|
||||
OPT_UTIL,
|
||||
OPT_METRICS,
|
||||
OPT_CMG,
|
||||
OPT_SCALE,
|
||||
OPT_NO_ANSI,
|
||||
OPT_NO_PREFIX,
|
||||
OPT_DEBUG,
|
||||
};
|
||||
|
||||
/*
|
||||
* Configuration of command line options
|
||||
*/
|
||||
static struct util_opt opt_vec[] = {
|
||||
{
|
||||
.desc = "ACTIONS",
|
||||
.flags = UTIL_OPT_FLAG_SECTION,
|
||||
},
|
||||
{
|
||||
.option = { "status", no_argument, NULL, OPT_STATUS },
|
||||
.desc = "Show channel-path statistics status",
|
||||
},
|
||||
{
|
||||
.option = { "enable", no_argument, NULL, OPT_ENABLE },
|
||||
.desc = "Enable channel-path statistics",
|
||||
},
|
||||
{
|
||||
.option = { "disable", no_argument, NULL, OPT_DISABLE },
|
||||
.desc = "Disable channel-path statistics",
|
||||
},
|
||||
{
|
||||
.option = { "list-columns", no_argument, NULL,
|
||||
OPT_LIST_COLUMNS},
|
||||
.desc = "List available table columns",
|
||||
},
|
||||
{
|
||||
.option = { "list-keys", no_argument, NULL, OPT_LIST_KEYS},
|
||||
.desc = "List available data keys",
|
||||
},
|
||||
UTIL_OPT_HELP,
|
||||
UTIL_OPT_VERSION,
|
||||
{
|
||||
.desc = "OPTIONS",
|
||||
.flags = UTIL_OPT_FLAG_SECTION,
|
||||
},
|
||||
{
|
||||
.option = { "iterations", required_argument, NULL,
|
||||
OPT_ITERATIONS },
|
||||
.argument = "NUM",
|
||||
.desc = "Display NUM reports before ending (0 for no end)",
|
||||
},
|
||||
{
|
||||
.option = { "interval", required_argument, NULL,
|
||||
OPT_INTERVAL },
|
||||
.argument = "NUM",
|
||||
.desc = "Pause NUM seconds between display",
|
||||
},
|
||||
{
|
||||
.option = { "columns", required_argument, NULL, OPT_COLUMNS },
|
||||
.argument = "COL,..",
|
||||
.desc = "Show only specified columns in table output",
|
||||
},
|
||||
{
|
||||
.option = { "keys", required_argument, NULL, OPT_KEYS },
|
||||
.argument = "KEY,..",
|
||||
.desc = "Show only data for specified keys in list output",
|
||||
},
|
||||
{
|
||||
.option = { "all", no_argument, NULL, OPT_ALL },
|
||||
.desc = "Show all table columns and key data",
|
||||
},
|
||||
{
|
||||
.option = { "scale", required_argument, NULL, OPT_SCALE },
|
||||
.argument = "UNIT",
|
||||
.flags = UTIL_OPT_FLAG_NOSHORT,
|
||||
.desc = "Scale BPS values by UNIT (number, suffix or auto)",
|
||||
},
|
||||
{
|
||||
.option = { "cmg", required_argument, NULL, OPT_CMG },
|
||||
.argument = "CMG,..",
|
||||
.flags = UTIL_OPT_FLAG_NOSHORT,
|
||||
.desc = "Show data for specified CMGs only",
|
||||
},
|
||||
{
|
||||
.option = { "format", required_argument, NULL, OPT_FORMAT },
|
||||
.argument = "FORMAT",
|
||||
.flags = UTIL_OPT_FLAG_NOSHORT,
|
||||
.desc = "List data in specified FORMAT (" FMT_TYPE_NAMES ")",
|
||||
},
|
||||
{
|
||||
.option = { "chars", no_argument, NULL, OPT_CHARS },
|
||||
.flags = UTIL_OPT_FLAG_NOSHORT,
|
||||
.desc = "List channel-path measurement characteristics",
|
||||
},
|
||||
{
|
||||
.option = { "util", no_argument, NULL, OPT_UTIL },
|
||||
.flags = UTIL_OPT_FLAG_NOSHORT,
|
||||
.desc = "List unprocessed utilization data",
|
||||
},
|
||||
{
|
||||
.option = { "metrics", no_argument, NULL, OPT_METRICS },
|
||||
.flags = UTIL_OPT_FLAG_NOSHORT,
|
||||
.desc = "List performance metrics",
|
||||
},
|
||||
{
|
||||
.option = { "no-ansi", no_argument, NULL, OPT_NO_ANSI },
|
||||
.flags = UTIL_OPT_FLAG_NOSHORT,
|
||||
.desc = "Do not use ANSI terminal codes in output",
|
||||
},
|
||||
{
|
||||
.option = { "no-prefix", no_argument, NULL, OPT_NO_PREFIX },
|
||||
.flags = UTIL_OPT_FLAG_NOSHORT,
|
||||
.desc = "Hide key prefix in pairs output format",
|
||||
},
|
||||
{
|
||||
.option = { "debug", no_argument, NULL, OPT_DEBUG },
|
||||
.flags = UTIL_OPT_FLAG_NOSHORT,
|
||||
.desc = "Print debugging information",
|
||||
},
|
||||
UTIL_OPT_END
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user