Rather than continually cut-n-paste the strings into each command,
create a common macro to be used generically. Note that not all
'{.name = "file",' entries are replaced, just those that use
VSH_OT_DATA and VSH_OFLAG_REQ.
Replacement of this option is a bit trickier, since the .helpstr
changes from command to command. Also because if the N_() I18N
for each, it's also not possible to just copy the string. So,
replace the enter right side of the .helpstr = with the _helpstr
macro argument.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
tools/virsh-domain.c | 85 +++++++++++++---------------------------------------
1 file changed, 20 insertions(+), 65 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 20627e9..8e28bb3 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -87,6 +87,13 @@
.help = N_("affect current domain") \
} \
+#define VIRSH_DOMAIN_FILE_OPT_COMMON(_helpstr) \
+ {.name = "file", \
+ .type = VSH_OT_DATA, \
+ .flags = VSH_OFLAG_REQ, \
+ .help = _helpstr \
+ } \
+
static virDomainPtr
virshLookupDomainInternal(vshControl *ctl,
const char *cmdname,
@@ -230,11 +237,7 @@ static const vshCmdInfo info_attach_device[] = {
static const vshCmdOptDef opts_attach_device[] = {
VIRSH_DOMAIN_OPT_COMMON,
- {.name = "file",
- .type = VSH_OT_DATA,
- .flags = VSH_OFLAG_REQ,
- .help = N_("XML file")
- },
+ VIRSH_DOMAIN_FILE_OPT_COMMON(N_("XML file")),
VIRSH_DOMAIN_PERSISTENT_OPT_COMMON,
VIRSH_DOMAIN_CONFIG_OPT_COMMON,
VIRSH_DOMAIN_LIVE_OPT_COMMON,
@@ -4135,11 +4138,7 @@ static const vshCmdInfo info_save[] = {
static const vshCmdOptDef opts_save[] = {
VIRSH_DOMAIN_OPT_COMMON,
- {.name = "file",
- .type = VSH_OT_DATA,
- .flags = VSH_OFLAG_REQ,
- .help = N_("where to save the data")
- },
+ VIRSH_DOMAIN_FILE_OPT_COMMON(N_("where to save the data")),
{.name = "bypass-cache",
.type = VSH_OT_BOOL,
.help = N_("avoid file system cache when saving")
@@ -4396,11 +4395,7 @@ static const vshCmdInfo info_save_image_dumpxml[] = {
};
static const vshCmdOptDef opts_save_image_dumpxml[] = {
- {.name = "file",
- .type = VSH_OT_DATA,
- .flags = VSH_OFLAG_REQ,
- .help = N_("saved state file to read")
- },
+ VIRSH_DOMAIN_FILE_OPT_COMMON(N_("saved state file to read")),
{.name = "security-info",
.type = VSH_OT_BOOL,
.help = N_("include security sensitive information in XML dump")
@@ -4449,11 +4444,7 @@ static const vshCmdInfo info_save_image_define[] = {
};
static const vshCmdOptDef opts_save_image_define[] = {
- {.name = "file",
- .type = VSH_OT_DATA,
- .flags = VSH_OFLAG_REQ,
- .help = N_("saved state file to modify")
- },
+ VIRSH_DOMAIN_FILE_OPT_COMMON(N_("saved state file to modify")),
{.name = "xml",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
@@ -4521,11 +4512,7 @@ static const vshCmdInfo info_save_image_edit[] = {
};
static const vshCmdOptDef opts_save_image_edit[] = {
- {.name = "file",
- .type = VSH_OT_DATA,
- .flags = VSH_OFLAG_REQ,
- .help = N_("saved state file to edit")
- },
+ VIRSH_DOMAIN_FILE_OPT_COMMON(N_("saved state file to edit")),
{.name = "running",
.type = VSH_OT_BOOL,
.help = N_("set domain to be running on restore")
@@ -5019,11 +5006,7 @@ static const vshCmdInfo info_restore[] = {
};
static const vshCmdOptDef opts_restore[] = {
- {.name = "file",
- .type = VSH_OT_DATA,
- .flags = VSH_OFLAG_REQ,
- .help = N_("the state to restore")
- },
+ VIRSH_DOMAIN_FILE_OPT_COMMON(N_("the state to restore")),
{.name = "bypass-cache",
.type = VSH_OT_BOOL,
.help = N_("avoid file system cache when restoring")
@@ -5100,11 +5083,7 @@ static const vshCmdInfo info_dump[] = {
static const vshCmdOptDef opts_dump[] = {
VIRSH_DOMAIN_OPT_COMMON,
- {.name = "file",
- .type = VSH_OT_DATA,
- .flags = VSH_OFLAG_REQ,
- .help = N_("where to dump the core")
- },
+ VIRSH_DOMAIN_FILE_OPT_COMMON(N_("where to dump the core")),
{.name = "live",
.type = VSH_OT_BOOL,
.help = N_("perform a live core dump if supported")
@@ -7045,11 +7024,7 @@ static const vshCmdInfo info_cpu_compare[] = {
};
static const vshCmdOptDef opts_cpu_compare[] = {
- {.name = "file",
- .type = VSH_OT_DATA,
- .flags = VSH_OFLAG_REQ,
- .help = N_("file containing an XML CPU description")
- },
+ VIRSH_DOMAIN_FILE_OPT_COMMON(N_("file containing an XML CPU
description")),
{.name = "error",
.type = VSH_OT_BOOL,
.help = N_("report error if CPUs are incompatible")
@@ -7147,11 +7122,7 @@ static const vshCmdInfo info_cpu_baseline[] = {
};
static const vshCmdOptDef opts_cpu_baseline[] = {
- {.name = "file",
- .type = VSH_OT_DATA,
- .flags = VSH_OFLAG_REQ,
- .help = N_("file containing XML CPU descriptions")
- },
+ VIRSH_DOMAIN_FILE_OPT_COMMON(N_("file containing XML CPU descriptions")),
{.name = "features",
.type = VSH_OT_BOOL,
.help = N_("Show features that are part of the CPU model type")
@@ -7449,11 +7420,7 @@ static const vshCmdInfo info_create[] = {
};
static const vshCmdOptDef opts_create[] = {
- {.name = "file",
- .type = VSH_OT_DATA,
- .flags = VSH_OFLAG_REQ,
- .help = N_("file containing an XML domain description")
- },
+ VIRSH_DOMAIN_FILE_OPT_COMMON(N_("file containing an XML domain
description")),
#ifndef WIN32
{.name = "console",
.type = VSH_OT_BOOL,
@@ -7549,11 +7516,7 @@ static const vshCmdInfo info_define[] = {
};
static const vshCmdOptDef opts_define[] = {
- {.name = "file",
- .type = VSH_OT_DATA,
- .flags = VSH_OFLAG_REQ,
- .help = N_("file containing an XML domain description")
- },
+ VIRSH_DOMAIN_FILE_OPT_COMMON(N_("file containing an XML domain
description")),
{.name = "validate",
.type = VSH_OT_BOOL,
.help = N_("validate the XML against the schema")
@@ -10684,11 +10647,7 @@ static const vshCmdInfo info_detach_device[] = {
static const vshCmdOptDef opts_detach_device[] = {
VIRSH_DOMAIN_OPT_COMMON,
- {.name = "file",
- .type = VSH_OT_DATA,
- .flags = VSH_OFLAG_REQ,
- .help = N_("XML file")
- },
+ VIRSH_DOMAIN_FILE_OPT_COMMON(N_("XML file")),
VIRSH_DOMAIN_PERSISTENT_OPT_COMMON,
VIRSH_DOMAIN_CONFIG_OPT_COMMON,
VIRSH_DOMAIN_LIVE_OPT_COMMON,
@@ -10769,11 +10728,7 @@ static const vshCmdInfo info_update_device[] = {
static const vshCmdOptDef opts_update_device[] = {
VIRSH_DOMAIN_OPT_COMMON,
- {.name = "file",
- .type = VSH_OT_DATA,
- .flags = VSH_OFLAG_REQ,
- .help = N_("XML file")
- },
+ VIRSH_DOMAIN_FILE_OPT_COMMON(N_("XML file")),
VIRSH_DOMAIN_PERSISTENT_OPT_COMMON,
VIRSH_DOMAIN_CONFIG_OPT_COMMON,
VIRSH_DOMAIN_LIVE_OPT_COMMON,
--
2.5.0