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 3387625..a055b47 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -94,6 +94,13 @@
.help = N_("affect current domain") \
} \
+#define VSH_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,
@@ -237,11 +244,7 @@ static const vshCmdInfo info_attach_device[] = {
static const vshCmdOptDef opts_attach_device[] = {
VSH_DOMAIN_OPT_COMMON,
- {.name = "file",
- .type = VSH_OT_DATA,
- .flags = VSH_OFLAG_REQ,
- .help = N_("XML file")
- },
+ VSH_DOMAIN_FILE_OPT_COMMON(N_("XML file")),
VSH_DOMAIN_PERSISTENT_OPT_COMMON,
VSH_DOMAIN_CONFIG_OPT_COMMON,
VSH_DOMAIN_LIVE_OPT_COMMON,
@@ -4142,11 +4145,7 @@ static const vshCmdInfo info_save[] = {
static const vshCmdOptDef opts_save[] = {
VSH_DOMAIN_OPT_COMMON,
- {.name = "file",
- .type = VSH_OT_DATA,
- .flags = VSH_OFLAG_REQ,
- .help = N_("where to save the data")
- },
+ VSH_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")
@@ -4403,11 +4402,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")
- },
+ VSH_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")
@@ -4456,11 +4451,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")
- },
+ VSH_DOMAIN_FILE_OPT_COMMON(N_("saved state file to modify")),
{.name = "xml",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
@@ -4528,11 +4519,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")
- },
+ VSH_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")
@@ -5026,11 +5013,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")
- },
+ VSH_DOMAIN_FILE_OPT_COMMON(N_("the state to restore")),
{.name = "bypass-cache",
.type = VSH_OT_BOOL,
.help = N_("avoid file system cache when restoring")
@@ -5107,11 +5090,7 @@ static const vshCmdInfo info_dump[] = {
static const vshCmdOptDef opts_dump[] = {
VSH_DOMAIN_OPT_COMMON,
- {.name = "file",
- .type = VSH_OT_DATA,
- .flags = VSH_OFLAG_REQ,
- .help = N_("where to dump the core")
- },
+ VSH_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")
@@ -7052,11 +7031,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")
- },
+ VSH_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")
@@ -7154,11 +7129,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")
- },
+ VSH_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")
@@ -7456,11 +7427,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")
- },
+ VSH_DOMAIN_FILE_OPT_COMMON(N_("file containing an XML domain
description")),
#ifndef WIN32
{.name = "console",
.type = VSH_OT_BOOL,
@@ -7556,11 +7523,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")
- },
+ VSH_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")
@@ -10691,11 +10654,7 @@ static const vshCmdInfo info_detach_device[] = {
static const vshCmdOptDef opts_detach_device[] = {
VSH_DOMAIN_OPT_COMMON,
- {.name = "file",
- .type = VSH_OT_DATA,
- .flags = VSH_OFLAG_REQ,
- .help = N_("XML file")
- },
+ VSH_DOMAIN_FILE_OPT_COMMON(N_("XML file")),
VSH_DOMAIN_PERSISTENT_OPT_COMMON,
VSH_DOMAIN_CONFIG_OPT_COMMON,
VSH_DOMAIN_LIVE_OPT_COMMON,
@@ -10776,11 +10735,7 @@ static const vshCmdInfo info_update_device[] = {
static const vshCmdOptDef opts_update_device[] = {
VSH_DOMAIN_OPT_COMMON,
- {.name = "file",
- .type = VSH_OT_DATA,
- .flags = VSH_OFLAG_REQ,
- .help = N_("XML file")
- },
+ VSH_DOMAIN_FILE_OPT_COMMON(N_("XML file")),
VSH_DOMAIN_PERSISTENT_OPT_COMMON,
VSH_DOMAIN_CONFIG_OPT_COMMON,
VSH_DOMAIN_LIVE_OPT_COMMON,
--
2.5.0