mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
zpwr: 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
68309ccb7f
commit
31d576a595
2
.gitignore
vendored
2
.gitignore
vendored
@@ -171,3 +171,5 @@ zpcictl/zpcictl
|
||||
zpcictl/_zpcictl
|
||||
zpcictl/zpcictl.bash
|
||||
zpwr/zpwr
|
||||
zpwr/_zpwr
|
||||
zpwr/zpwr.bash
|
||||
|
||||
@@ -7,6 +7,11 @@
|
||||
|
||||
include ../common.mak
|
||||
|
||||
zsh-completions = _zpwr
|
||||
bash-completions = zpwr.bash
|
||||
|
||||
include ../common_autocomp.mak
|
||||
|
||||
all: zpwr
|
||||
|
||||
OBJECTS = zpwr.o
|
||||
|
||||
16
zpwr/autocompletion_generator_host.c
Normal file
16
zpwr/autocompletion_generator_host.c
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Copyright IBM Corp.
|
||||
*/
|
||||
|
||||
#include "lib/util_autocomp.h"
|
||||
|
||||
#include "zpwr_cli.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
generate_autocomp(opt_vec, "zpwr");
|
||||
|
||||
return 0;
|
||||
}
|
||||
30
zpwr/zpwr.c
30
zpwr/zpwr.c
@@ -29,14 +29,15 @@
|
||||
#include "lib/util_fmt.h"
|
||||
#include "lib/util_opt.h"
|
||||
#include "lib/util_prg.h"
|
||||
|
||||
#include "zpwr.h"
|
||||
#include "zpwr_cli.h"
|
||||
|
||||
#define DIAG "/dev/diag"
|
||||
#define NANO 1000000000ULL
|
||||
#define NUMUNIT 5
|
||||
#define NAMELEN 8
|
||||
#define COMPWIDTH 27
|
||||
#define OPT_FORMAT 256
|
||||
|
||||
enum part_power {
|
||||
CPU,
|
||||
@@ -95,33 +96,6 @@ static const struct util_prg prg = {
|
||||
}
|
||||
};
|
||||
|
||||
static struct util_opt opt_vec[] = {
|
||||
UTIL_OPT_SECTION("OPTIONS"),
|
||||
{
|
||||
.option = { "format", required_argument, NULL, OPT_FORMAT },
|
||||
.argument = "FORMAT",
|
||||
.flags = UTIL_OPT_FLAG_NOSHORT,
|
||||
.desc = "List data in specified FORMAT (" FMT_TYPE_NAMES ")",
|
||||
},
|
||||
{
|
||||
.option = { "delay", required_argument, NULL, 'd' },
|
||||
.argument = "NUMBER",
|
||||
.desc = "Power readings after delay (seconds)",
|
||||
},
|
||||
{
|
||||
.option = { "count", required_argument, NULL, 'c' },
|
||||
.argument = "NUMBER",
|
||||
.desc = "Number of power readings",
|
||||
},
|
||||
{
|
||||
.option = { "stream", no_argument, NULL, 's' },
|
||||
.desc = "Power readings in stream mode",
|
||||
},
|
||||
UTIL_OPT_HELP,
|
||||
UTIL_OPT_VERSION,
|
||||
UTIL_OPT_END
|
||||
};
|
||||
|
||||
static int get_max_column_width(struct zpwrinfo *pinfo)
|
||||
{
|
||||
u64 max = 0;
|
||||
|
||||
42
zpwr/zpwr_cli.h
Normal file
42
zpwr/zpwr_cli.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Copyright IBM Corp.
|
||||
*/
|
||||
|
||||
#ifndef ZPWR_CLI_H
|
||||
#define ZPWR_CLI_H
|
||||
|
||||
#include "lib/util_fmt.h"
|
||||
#include "lib/util_opt.h"
|
||||
|
||||
#define OPT_FORMAT 256
|
||||
|
||||
static struct util_opt opt_vec[] = {
|
||||
UTIL_OPT_SECTION("OPTIONS"),
|
||||
{
|
||||
.option = { "format", required_argument, NULL, OPT_FORMAT },
|
||||
.argument = "FORMAT",
|
||||
.flags = UTIL_OPT_FLAG_NOSHORT,
|
||||
.desc = "List data in specified FORMAT (" FMT_TYPE_NAMES ")",
|
||||
},
|
||||
{
|
||||
.option = { "delay", required_argument, NULL, 'd' },
|
||||
.argument = "NUMBER",
|
||||
.desc = "Power readings after delay (seconds)",
|
||||
},
|
||||
{
|
||||
.option = { "count", required_argument, NULL, 'c' },
|
||||
.argument = "NUMBER",
|
||||
.desc = "Number of power readings",
|
||||
},
|
||||
{
|
||||
.option = { "stream", no_argument, NULL, 's' },
|
||||
.desc = "Power readings in stream mode",
|
||||
},
|
||||
UTIL_OPT_HELP,
|
||||
UTIL_OPT_VERSION,
|
||||
UTIL_OPT_END
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user