
On 01/11/2016 09:38 AM, Andrea Bolognani wrote:
On Sat, 2016-01-09 at 08:36 -0500, John Ferlan wrote:
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 ----- -------- - ^ entire ^ .help ^ assignment (?)
I've nixed the whole paragraph
macro argument.
Signed-off-by: John Ferlan <jferlan@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 e3ed216..ce698c3 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -87,6 +87,13 @@ .help = N_("affect current domain") \ } \
+#define VIRSH_COMMON_OPT_DOMAIN_FILE(_helpstr) \ + {.name = "file", \ + .type = VSH_OT_DATA, \ + .flags = VSH_OFLAG_REQ, \ + .help = _helpstr \ + } \ +
I don't think this should be specific to domain commands. I'd rather rename it to VIRSH_COMMON_OPT_FILE(), move it to virsh.h and use it for
iface-define net-create net-define nodedev-create nwfilter-define secret-define vol-create vol-create-from vol-upload vol-download
too. Even better, you could change
#define VIRSH_COMMON_OPT_POOL_FILE \ VIRSH_COMMON_OPT_FILE(N_("file containing an XML pool description"))
and add
#define VIRSH_COMMON_OPT_VOLUME_FILE \ VIRSH_COMMON_OPT_FILE(N_("file containing an XML vol description"))
to use in the vol-* commands listed above.
All are adjusted now to use a common virsh.h VIRSH_COMMON_OPT_FILE macro (except of course the one oddball - opts_screenshot in domain_conf Tks - John