mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
dump2tar: 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
e7e9f137c1
commit
0eae712cc2
4
.gitignore
vendored
4
.gitignore
vendored
@@ -25,7 +25,7 @@ compile_commands.json
|
|||||||
#
|
#
|
||||||
**/.detect-openssl.dep.c
|
**/.detect-openssl.dep.c
|
||||||
*.debug
|
*.debug
|
||||||
*/autocompletion_generator_host
|
**/autocompletion_generator_host
|
||||||
ap_tools/ap-check
|
ap_tools/ap-check
|
||||||
cmsfs-fuse/cmsfs-fuse
|
cmsfs-fuse/cmsfs-fuse
|
||||||
cpacfstats/cpacfstats
|
cpacfstats/cpacfstats
|
||||||
@@ -56,6 +56,8 @@ dasdview/dasdview
|
|||||||
dasdview/_dasdview
|
dasdview/_dasdview
|
||||||
dasdview/dasdview.bash
|
dasdview/dasdview.bash
|
||||||
dump2tar/src/dump2tar
|
dump2tar/src/dump2tar
|
||||||
|
dump2tar/src/_dump2tar
|
||||||
|
dump2tar/src/dump2tar.bash
|
||||||
fdasd/fdasd
|
fdasd/fdasd
|
||||||
hmcdrvfs/hmcdrvfs
|
hmcdrvfs/hmcdrvfs
|
||||||
hsavmcore/check-dep-fuse
|
hsavmcore/check-dep-fuse
|
||||||
|
|||||||
136
dump2tar/include/dump2tar_cli.h
Normal file
136
dump2tar/include/dump2tar_cli.h
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*
|
||||||
|
* Copyright IBM Corp.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DUMP2TAR_CLI_H
|
||||||
|
#define DUMP2TAR_CLI_H
|
||||||
|
|
||||||
|
#include "lib/util_opt.h"
|
||||||
|
|
||||||
|
#define OPT_NOSHORT_BASE 256
|
||||||
|
|
||||||
|
#define OPT_DEREFERENCE (OPT_NOSHORT_BASE + 0)
|
||||||
|
#define OPT_NORECURSION (OPT_NOSHORT_BASE + 1)
|
||||||
|
#define OPT_EXCLUDETYPE (OPT_NOSHORT_BASE + 2)
|
||||||
|
|
||||||
|
/* Definition of command line options */
|
||||||
|
static struct util_opt dump2tar_opts[] = {
|
||||||
|
UTIL_OPT_SECTION("OUTPUT OPTIONS"),
|
||||||
|
{
|
||||||
|
.option = { "output-file", required_argument, NULL, 'o' },
|
||||||
|
.argument = "FILE",
|
||||||
|
.desc = "Write archive to FILE (default: standard output)",
|
||||||
|
},
|
||||||
|
#ifdef HAVE_ZLIB
|
||||||
|
{
|
||||||
|
.option = { "gzip", no_argument, NULL, 'z' },
|
||||||
|
.desc = "Write a gzip compressed archive",
|
||||||
|
},
|
||||||
|
#endif /* HAVE_ZLIB */
|
||||||
|
{
|
||||||
|
.option = { "max-size", required_argument, NULL, 'm' },
|
||||||
|
.argument = "N",
|
||||||
|
.desc = "Stop adding files when archive size exceeds N bytes",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.option = { "timeout", required_argument, NULL, 't' },
|
||||||
|
.argument = "SEC",
|
||||||
|
.desc = "Stop adding files after SEC seconds",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.option = { "no-eof", no_argument, NULL, 131 },
|
||||||
|
.desc = "Do not write an end-of-file marker",
|
||||||
|
.flags = UTIL_OPT_FLAG_NOSHORT,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.option = { "add-cmd-status", no_argument, NULL, 132 },
|
||||||
|
.desc = "Add status of commands as separate file",
|
||||||
|
.flags = UTIL_OPT_FLAG_NOSHORT,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.option = { "append", no_argument, NULL, 133 },
|
||||||
|
.desc = "Append output to end of file",
|
||||||
|
.flags = UTIL_OPT_FLAG_NOSHORT,
|
||||||
|
},
|
||||||
|
|
||||||
|
UTIL_OPT_SECTION("INPUT OPTIONS"),
|
||||||
|
{
|
||||||
|
.option = { "files-from", required_argument, NULL, 'F' },
|
||||||
|
.argument = "FILE",
|
||||||
|
.desc = "Read filenames from FILE (- for standard input)",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.option = { "ignore-failed-read", no_argument, NULL, 'i' },
|
||||||
|
.desc = "Continue after read errors",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.option = { "buffer-size", required_argument, NULL, 'b' },
|
||||||
|
.argument = "N",
|
||||||
|
.desc = "Read data in chunks of N byte (default: 16384)",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.option = { "file-timeout", required_argument, NULL, 'T' },
|
||||||
|
.desc = "Stop reading file after SEC seconds",
|
||||||
|
.argument = "SEC",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.option = { "file-max-size", required_argument, NULL, 'M' },
|
||||||
|
.argument = "N",
|
||||||
|
.desc = "Stop reading file after N bytes",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.option = { "jobs", required_argument, NULL, 'j' },
|
||||||
|
.argument = "N",
|
||||||
|
.desc = "Read N files in parallel (default: 1)",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.option = { "jobs-per-cpu", required_argument, NULL, 'J' },
|
||||||
|
.argument = "N",
|
||||||
|
.desc = "Read N files per CPU in parallel",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.option = { "exclude", required_argument, NULL, 'x' },
|
||||||
|
.argument = "PATTERN",
|
||||||
|
.desc = "Don't add files matching PATTERN",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.option = { "exclude-from", required_argument, NULL, 'X' },
|
||||||
|
.argument = "FILE",
|
||||||
|
.desc = "Don't add files matching patterns in FILE",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.option = { "exclude-type", required_argument, NULL,
|
||||||
|
OPT_EXCLUDETYPE },
|
||||||
|
.argument = "TYPE",
|
||||||
|
.desc = "Don't add files of specified TYPE (one of: fdcbpls)",
|
||||||
|
.flags = UTIL_OPT_FLAG_NOSHORT,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.option = { "dereference", no_argument, NULL, OPT_DEREFERENCE },
|
||||||
|
.desc = "Add link targets instead of links",
|
||||||
|
.flags = UTIL_OPT_FLAG_NOSHORT,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.option = { "no-recursion", no_argument, NULL,
|
||||||
|
OPT_NORECURSION },
|
||||||
|
.desc = "Don't add files from sub-directories",
|
||||||
|
.flags = UTIL_OPT_FLAG_NOSHORT,
|
||||||
|
},
|
||||||
|
|
||||||
|
UTIL_OPT_SECTION("MISC OPTIONS"),
|
||||||
|
UTIL_OPT_HELP,
|
||||||
|
UTIL_OPT_VERSION,
|
||||||
|
{
|
||||||
|
.option = { "verbose", no_argument, NULL, 'V' },
|
||||||
|
.desc = "Print additional informational output",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.option = { "quiet", no_argument, NULL, 'q' },
|
||||||
|
.desc = "Suppress printing of informational output",
|
||||||
|
},
|
||||||
|
UTIL_OPT_END,
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,6 +1,11 @@
|
|||||||
# Common definitions
|
# Common definitions
|
||||||
include ../../common.mak
|
include ../../common.mak
|
||||||
|
|
||||||
|
zsh-completions = _dump2tar
|
||||||
|
bash-completions = dump2tar.bash
|
||||||
|
|
||||||
|
include ../../common_autocomp.mak
|
||||||
|
|
||||||
ALL_CPPFLAGS += -I../include -Wno-unused-parameter
|
ALL_CPPFLAGS += -I../include -Wno-unused-parameter
|
||||||
LDLIBS += -lpthread -lrt
|
LDLIBS += -lpthread -lrt
|
||||||
ifneq ($(HAVE_ZLIB),0)
|
ifneq ($(HAVE_ZLIB),0)
|
||||||
|
|||||||
16
dump2tar/src/autocompletion_generator_host.c
Normal file
16
dump2tar/src/autocompletion_generator_host.c
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*
|
||||||
|
* Copyright IBM Corp.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "lib/util_autocomp.h"
|
||||||
|
|
||||||
|
#include "../include/dump2tar_cli.h"
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
generate_autocomp(dump2tar_opts, "dump2tar");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "lib/util_prg.h"
|
#include "lib/util_prg.h"
|
||||||
|
|
||||||
#include "dump.h"
|
#include "dump.h"
|
||||||
|
#include "dump2tar_cli.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "idcache.h"
|
#include "idcache.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
@@ -28,12 +29,6 @@
|
|||||||
|
|
||||||
#define MIN_BUFFER_SIZE 4096
|
#define MIN_BUFFER_SIZE 4096
|
||||||
|
|
||||||
#define OPT_NOSHORT_BASE 256
|
|
||||||
|
|
||||||
#define OPT_DEREFERENCE (OPT_NOSHORT_BASE + 0)
|
|
||||||
#define OPT_NORECURSION (OPT_NOSHORT_BASE + 1)
|
|
||||||
#define OPT_EXCLUDETYPE (OPT_NOSHORT_BASE + 2)
|
|
||||||
|
|
||||||
/* Program description */
|
/* Program description */
|
||||||
static const struct util_prg dump2tar_prg = {
|
static const struct util_prg dump2tar_prg = {
|
||||||
.desc = "Use dump2tar to create a tar archive from the contents "
|
.desc = "Use dump2tar to create a tar archive from the contents "
|
||||||
@@ -52,124 +47,6 @@ static const struct util_prg dump2tar_prg = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Definition of command line options */
|
|
||||||
static struct util_opt dump2tar_opts[] = {
|
|
||||||
UTIL_OPT_SECTION("OUTPUT OPTIONS"),
|
|
||||||
{
|
|
||||||
.option = { "output-file", required_argument, NULL, 'o' },
|
|
||||||
.argument = "FILE",
|
|
||||||
.desc = "Write archive to FILE (default: standard output)",
|
|
||||||
},
|
|
||||||
#ifdef HAVE_ZLIB
|
|
||||||
{
|
|
||||||
.option = { "gzip", no_argument, NULL, 'z' },
|
|
||||||
.desc = "Write a gzip compressed archive",
|
|
||||||
},
|
|
||||||
#endif /* HAVE_ZLIB */
|
|
||||||
{
|
|
||||||
.option = { "max-size", required_argument, NULL, 'm' },
|
|
||||||
.argument = "N",
|
|
||||||
.desc = "Stop adding files when archive size exceeds N bytes",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.option = { "timeout", required_argument, NULL, 't' },
|
|
||||||
.argument = "SEC",
|
|
||||||
.desc = "Stop adding files after SEC seconds",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.option = { "no-eof", no_argument, NULL, 131 },
|
|
||||||
.desc = "Do not write an end-of-file marker",
|
|
||||||
.flags = UTIL_OPT_FLAG_NOSHORT,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.option = { "add-cmd-status", no_argument, NULL, 132 },
|
|
||||||
.desc = "Add status of commands as separate file",
|
|
||||||
.flags = UTIL_OPT_FLAG_NOSHORT,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.option = { "append", no_argument, NULL, 133 },
|
|
||||||
.desc = "Append output to end of file",
|
|
||||||
.flags = UTIL_OPT_FLAG_NOSHORT,
|
|
||||||
},
|
|
||||||
|
|
||||||
UTIL_OPT_SECTION("INPUT OPTIONS"),
|
|
||||||
{
|
|
||||||
.option = { "files-from", required_argument, NULL, 'F' },
|
|
||||||
.argument = "FILE",
|
|
||||||
.desc = "Read filenames from FILE (- for standard input)",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.option = { "ignore-failed-read", no_argument, NULL, 'i' },
|
|
||||||
.desc = "Continue after read errors",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.option = { "buffer-size", required_argument, NULL, 'b' },
|
|
||||||
.argument = "N",
|
|
||||||
.desc = "Read data in chunks of N byte (default: 16384)",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.option = { "file-timeout", required_argument, NULL, 'T' },
|
|
||||||
.desc = "Stop reading file after SEC seconds",
|
|
||||||
.argument = "SEC",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.option = { "file-max-size", required_argument, NULL, 'M' },
|
|
||||||
.argument = "N",
|
|
||||||
.desc = "Stop reading file after N bytes",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.option = { "jobs", required_argument, NULL, 'j' },
|
|
||||||
.argument = "N",
|
|
||||||
.desc = "Read N files in parallel (default: 1)",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.option = { "jobs-per-cpu", required_argument, NULL, 'J' },
|
|
||||||
.argument = "N",
|
|
||||||
.desc = "Read N files per CPU in parallel",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.option = { "exclude", required_argument, NULL, 'x' },
|
|
||||||
.argument = "PATTERN",
|
|
||||||
.desc = "Don't add files matching PATTERN",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.option = { "exclude-from", required_argument, NULL, 'X' },
|
|
||||||
.argument = "FILE",
|
|
||||||
.desc = "Don't add files matching patterns in FILE",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.option = { "exclude-type", required_argument, NULL,
|
|
||||||
OPT_EXCLUDETYPE },
|
|
||||||
.argument = "TYPE",
|
|
||||||
.desc = "Don't add files of specified TYPE (one of: fdcbpls)",
|
|
||||||
.flags = UTIL_OPT_FLAG_NOSHORT,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.option = { "dereference", no_argument, NULL, OPT_DEREFERENCE },
|
|
||||||
.desc = "Add link targets instead of links",
|
|
||||||
.flags = UTIL_OPT_FLAG_NOSHORT,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.option = { "no-recursion", no_argument, NULL,
|
|
||||||
OPT_NORECURSION },
|
|
||||||
.desc = "Don't add files from sub-directories",
|
|
||||||
.flags = UTIL_OPT_FLAG_NOSHORT,
|
|
||||||
},
|
|
||||||
|
|
||||||
UTIL_OPT_SECTION("MISC OPTIONS"),
|
|
||||||
UTIL_OPT_HELP,
|
|
||||||
UTIL_OPT_VERSION,
|
|
||||||
{
|
|
||||||
.option = { "verbose", no_argument, NULL, 'V' },
|
|
||||||
.desc = "Print additional informational output",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.option = { "quiet", no_argument, NULL, 'q' },
|
|
||||||
.desc = "Suppress printing of informational output",
|
|
||||||
},
|
|
||||||
UTIL_OPT_END,
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Split buffer size specification in @arg into two numbers to be stored in
|
/* Split buffer size specification in @arg into two numbers to be stored in
|
||||||
* @from_ptr and @to_ptr. Return %EXIT_OK on success. */
|
* @from_ptr and @to_ptr. Return %EXIT_OK on success. */
|
||||||
static int parse_buffer_size(char *arg, size_t *from_ptr, size_t *to_ptr)
|
static int parse_buffer_size(char *arg, size_t *from_ptr, size_t *to_ptr)
|
||||||
|
|||||||
Reference in New Issue
Block a user