From bbcbaf494ad406ceea4f0175b91cf67966d32a27 Mon Sep 17 00:00:00 2001 From: Prasanna Kumar Kalever Date: Fri, 3 Feb 2017 18:34:07 +0530 Subject: cli: deprecated getopts_long usage deprecated getopts as to eliminate use of '--' with command line options The new usage looks like: gluster-block (Version 0.1) create Create the gluster block volserver [gluster-node] node addr from gluster pool(def: localhost) size block storage size in KiB|MiB|GiB|TiB.. mpath multi path requirement for high availablity servers [] block servers, clubbed with any option list List available gluster blocks info Details about gluster block modify Modify the metadata delete Delete the gluster block volume gluster volume name Signed-off-by: Prasanna Kumar Kalever --- utils.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'utils.c') diff --git a/utils.c b/utils.c index ee3515f..059fb6b 100644 --- a/utils.c +++ b/utils.c @@ -13,6 +13,65 @@ +int +glusterBlockCLIOptEnumParse(const char *opt) +{ + int i; + + + if (!opt) { + return GB_CLI_OPT_MAX; + } + + for (i = 0; i < GB_CLI_OPT_MAX; i++) { + if (!strcmp(opt, gbCmdlineOptLookup[i])) { + return i; + } + } + + return i; +} + +int +glusterBlockCLICreateOptEnumParse(const char *opt) +{ + int i; + + + if (!opt) { + return GB_CLI_CREATE_OPT_MAX; + } + + /* i = 11, enum start look gbCmdlineCreateOption */ + for (i = 11; i < GB_CLI_CREATE_OPT_MAX; i++) { + if (!strcmp(opt, gbCmdlineCreateOptLookup[i])) { + return i; + } + } + + return i; +} + +int +glusterBlockCLICommonOptEnumParse(const char *opt) +{ + int i; + + + if (!opt) { + return GB_CLI_COMMON_OPT_MAX; + } + + /* i = 21, enum start look gbCmdlineCreateOption */ + for (i = 21; i < GB_CLI_COMMON_OPT_MAX; i++) { + if (!strcmp(opt, gbCmdlineCommonOptLookup[i])) { + return i; + } + } + + return i; +} + int blockMetaKeyEnumParse(const char *opt) { -- cgit