diff --git a/.gitignore b/.gitignore index 510acffe..91997079 100644 --- a/.gitignore +++ b/.gitignore @@ -53,6 +53,8 @@ dasdinfo/dasdinfo dasdinfo/_dasdinfo dasdinfo/dasdinfo.bash dasdview/dasdview +dasdview/_dasdview +dasdview/dasdview.bash dump2tar/src/dump2tar fdasd/fdasd hmcdrvfs/hmcdrvfs diff --git a/dasdview/Makefile b/dasdview/Makefile index be89305a..ce268910 100644 --- a/dasdview/Makefile +++ b/dasdview/Makefile @@ -1,5 +1,10 @@ include ../common.mak +zsh-completions = _dasdview +bash-completions = dasdview.bash + +include ../common_autocomp.mak + libs = $(rootdir)/libdasd/libdasd.a \ $(rootdir)/libzds/libzds.a \ $(rootdir)/libvtoc/libvtoc.a \ diff --git a/dasdview/autocompletion_generator_host.c b/dasdview/autocompletion_generator_host.c new file mode 100644 index 00000000..903cc1b3 --- /dev/null +++ b/dasdview/autocompletion_generator_host.c @@ -0,0 +1,16 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright IBM Corp. + */ + +#include "lib/util_autocomp.h" + +#include "dasdview_cli.h" + +int main(void) +{ + generate_autocomp(opt_vec, "dasdview"); + + return 0; +} diff --git a/dasdview/dasdview.c b/dasdview/dasdview.c index 0060a761..d4cbc9c5 100644 --- a/dasdview/dasdview.c +++ b/dasdview/dasdview.c @@ -37,6 +37,7 @@ #include "lib/zt_common.h" #include "dasdview.h" +#include "dasdview_cli.h" /* Characters per line */ #define DASDVIEW_CPL 16 @@ -56,61 +57,6 @@ static const struct util_prg prg = { } }; -static struct util_opt opt_vec[] = { - UTIL_OPT_SECTION("DUMP OPTIONS"), - { - .option = { NULL, no_argument, NULL, '1' }, - .desc = "Show DASD content in short Hex/EBCDIC/ASCII format", - .flags = UTIL_OPT_FLAG_NOLONG, - }, - { - .option = { NULL, no_argument, NULL, '2' }, - .desc = "Show DASD content in detailed Hex/EBCDIC/ASCII format", - .flags = UTIL_OPT_FLAG_NOLONG, - }, - { - .option = { "begin", required_argument, NULL, 'b' }, - .argument = "BEGIN", - .desc = "Specify start of dump in kilobytes (suffix k), " - "megabytes (m), blocks (b), tracks (t), or cylinders (c)", - }, - { - .option = { "size", required_argument, NULL, 's' }, - .argument = "SIZE", - .desc = "Specify size of dump in kilobytes (suffix k), " - "megabytes (m), blocks (b), tracks (t), or cylinders (c)", - }, - UTIL_OPT_SECTION("MISC"), - { - .option = { "characteristic", no_argument, NULL, 'c' }, - .desc = "Print the characteristics of a device", - }, - { - .option = { "info", no_argument, NULL, 'i' }, - .desc = "Print general DASD information and geometry", - }, - { - .option = { "volser", no_argument, NULL, 'j' }, - .desc = "Print the volume serial number", - }, - { - .option = { "label", no_argument, NULL, 'l' }, - .desc = "Print information about the volume label", - }, - { - .option = { "vtoc", required_argument, NULL, 't' }, - .argument = "SPEC", - .desc = "Print the table of content (VTOC)", - }, - { - .option = { "extended", no_argument, NULL, 'x' }, - .desc = "Print extended DASD information", - }, - UTIL_OPT_HELP, - UTIL_OPT_VERSION, - UTIL_OPT_END -}; - /* * Generate and print an error message based on the formatted * text string FMT and a variable amount of extra arguments. diff --git a/dasdview/dasdview_cli.h b/dasdview/dasdview_cli.h new file mode 100644 index 00000000..e405d51b --- /dev/null +++ b/dasdview/dasdview_cli.h @@ -0,0 +1,67 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright IBM Corp. + */ + +#ifndef DASDVIEW_CLI_H +#define DASDVIEW_CLI_H + +#include "lib/util_opt.h" + +static struct util_opt opt_vec[] = { + UTIL_OPT_SECTION("DUMP OPTIONS"), + { + .option = { NULL, no_argument, NULL, '1' }, + .desc = "Show DASD content in short Hex/EBCDIC/ASCII format", + .flags = UTIL_OPT_FLAG_NOLONG, + }, + { + .option = { NULL, no_argument, NULL, '2' }, + .desc = "Show DASD content in detailed Hex/EBCDIC/ASCII format", + .flags = UTIL_OPT_FLAG_NOLONG, + }, + { + .option = { "begin", required_argument, NULL, 'b' }, + .argument = "BEGIN", + .desc = "Specify start of dump in kilobytes (suffix k), " + "megabytes (m), blocks (b), tracks (t), or cylinders (c)", + }, + { + .option = { "size", required_argument, NULL, 's' }, + .argument = "SIZE", + .desc = "Specify size of dump in kilobytes (suffix k), " + "megabytes (m), blocks (b), tracks (t), or cylinders (c)", + }, + UTIL_OPT_SECTION("MISC"), + { + .option = { "characteristic", no_argument, NULL, 'c' }, + .desc = "Print the characteristics of a device", + }, + { + .option = { "info", no_argument, NULL, 'i' }, + .desc = "Print general DASD information and geometry", + }, + { + .option = { "volser", no_argument, NULL, 'j' }, + .desc = "Print the volume serial number", + }, + { + .option = { "label", no_argument, NULL, 'l' }, + .desc = "Print information about the volume label", + }, + { + .option = { "vtoc", required_argument, NULL, 't' }, + .argument = "SPEC", + .desc = "Print the table of content (VTOC)", + }, + { + .option = { "extended", no_argument, NULL, 'x' }, + .desc = "Print extended DASD information", + }, + UTIL_OPT_HELP, + UTIL_OPT_VERSION, + UTIL_OPT_END +}; + +#endif