[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
[libvirt] [PATCH 03/13] add VSH_OFLAG_REQ_OPT options
- From: Lai Jiangshan <laijs cn fujitsu com>
- To: Eric Blake <eblake redhat com>, "Daniel P. Berrange" <berrange redhat com>
- Cc: Lai Jiangshan <laijs fujitsu com>, libvirt-list redhat com
- Subject: [libvirt] [PATCH 03/13] add VSH_OFLAG_REQ_OPT options
- Date: Wed, 25 May 2011 17:37:45 +0800
A VSH_OFLAG_REQ_OPT option means --optionname is required when used.
It will kill any ambiguity even !VSH_OFLAG_REQ option listed before
VSH_OFLAG_REQ option if the !VSH_OFLAG_REQ option is a VSH_OFLAG_REQ_OPT option.
It will help us use optional arguement with VSH_OT_ARGV argument.
Signed-off-by: Lai Jiangshan <laijs fujitsu com>
---
tools/virsh.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 2e27535..80cffac 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -152,6 +152,7 @@ enum {
VSH_OFLAG_NONE = 0, /* without flags */
VSH_OFLAG_REQ = (1 << 0), /* option required */
VSH_OFLAG_EMPTY_OK = (1 << 1), /* empty string option allowed */
+ VSH_OFLAG_REQ_OPT = (1 << 2), /* --optionname required */
};
/* dummy */
@@ -11080,6 +11081,12 @@ vshCmddefOptParse(const vshCmdDef *cmd, uint32_t* opts_need_arg,
return -1; /* bool options can't be mandatory */
continue;
}
+ if (opt->flag & VSH_OFLAG_REQ_OPT) {
+ if (opt->flag & VSH_OFLAG_REQ)
+ *opts_required |= 1 << i;
+ continue;
+ }
+
*opts_need_arg |= 1 << i;
if (opt->flag & VSH_OFLAG_REQ) {
if (optional)
--
1.7.4.4
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]