mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
test-tool: implement --short-options & --long-options
While not useful per-se, it will help checking the available options.
This commit is contained in:
@@ -22,11 +22,14 @@ EXTRA_DIST = libguestfs-test-tool.pod
|
|||||||
bin_PROGRAMS = libguestfs-test-tool
|
bin_PROGRAMS = libguestfs-test-tool
|
||||||
man_MANS = libguestfs-test-tool.1
|
man_MANS = libguestfs-test-tool.1
|
||||||
|
|
||||||
libguestfs_test_tool_SOURCES = test-tool.c
|
libguestfs_test_tool_SOURCES = \
|
||||||
|
../common/options/display-options.c \
|
||||||
|
test-tool.c
|
||||||
|
|
||||||
libguestfs_test_tool_CPPFLAGS = \
|
libguestfs_test_tool_CPPFLAGS = \
|
||||||
-I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \
|
-I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \
|
||||||
-I$(top_srcdir)/lib -I$(top_builddir)/lib \
|
-I$(top_srcdir)/lib -I$(top_builddir)/lib \
|
||||||
|
-I$(top_srcdir)/common/options -I$(top_builddir)/common/options \
|
||||||
-I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \
|
-I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \
|
||||||
-DGUESTFS_WARN_DEPRECATED=1 \
|
-DGUESTFS_WARN_DEPRECATED=1 \
|
||||||
-DLOCALEBASEDIR=\""$(datadir)/locale"\"
|
-DLOCALEBASEDIR=\""$(datadir)/locale"\"
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
|
|
||||||
#include "guestfs.h"
|
#include "guestfs.h"
|
||||||
#include "guestfs-utils.h"
|
#include "guestfs-utils.h"
|
||||||
|
#include "display-options.h"
|
||||||
|
|
||||||
#include "ignore-value.h"
|
#include "ignore-value.h"
|
||||||
|
|
||||||
@@ -81,8 +82,10 @@ main (int argc, char *argv[])
|
|||||||
static const char options[] = "t:V?";
|
static const char options[] = "t:V?";
|
||||||
static const struct option long_options[] = {
|
static const struct option long_options[] = {
|
||||||
{ "help", 0, 0, '?' },
|
{ "help", 0, 0, '?' },
|
||||||
|
{ "long-options", 0, 0, 0 },
|
||||||
{ "qemu", 1, 0, 0 },
|
{ "qemu", 1, 0, 0 },
|
||||||
{ "qemudir", 1, 0, 0 },
|
{ "qemudir", 1, 0, 0 },
|
||||||
|
{ "short-options", 0, 0, 0 },
|
||||||
{ "timeout", 1, 0, 't' },
|
{ "timeout", 1, 0, 't' },
|
||||||
{ "version", 0, 0, 'V' },
|
{ "version", 0, 0, 'V' },
|
||||||
{ 0, 0, 0, 0 }
|
{ 0, 0, 0, 0 }
|
||||||
@@ -103,7 +106,11 @@ main (int argc, char *argv[])
|
|||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 0: /* options which are long only */
|
case 0: /* options which are long only */
|
||||||
if (STREQ (long_options[option_index].name, "qemu")) {
|
if (STREQ (long_options[option_index].name, "long-options"))
|
||||||
|
display_long_options (long_options);
|
||||||
|
else if (STREQ (long_options[option_index].name, "short-options"))
|
||||||
|
display_short_options (options);
|
||||||
|
else if (STREQ (long_options[option_index].name, "qemu")) {
|
||||||
qemu = optarg;
|
qemu = optarg;
|
||||||
qemu_use_wrapper = 0;
|
qemu_use_wrapper = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user