From d7775f350c3c96dcf5c2eea7097cd42e980eb4f2 Mon Sep 17 00:00:00 2001 From: Prasanna Kumar Kalever Date: Wed, 15 Feb 2017 18:53:59 +0530 Subject: cli: add command to furnish pkg version info Improvements: Version info displaying. Improve help menu. This patch also makes 'mpath' option as optional (default: 1) Signed-off-by: Prasanna Kumar Kalever --- cli/Makefile.am | 3 ++- cli/gluster-block.c | 67 +++++++++++++++++++++++++++++++++-------------------- 2 files changed, 44 insertions(+), 26 deletions(-) (limited to 'cli') diff --git a/cli/Makefile.am b/cli/Makefile.am index 27a9a8a..f386a85 100644 --- a/cli/Makefile.am +++ b/cli/Makefile.am @@ -6,7 +6,8 @@ gluster_block_LDADD = $(top_srcdir)/rpc/libgbxdr.la \ $(top_srcdir)/utils/libgb.la gluster_block_CFLAGS = -DDATADIR=\"$(localstatedir)\" \ - -I$(top_srcdir)/utils/ -I$(top_srcdir)/rpc + -I$(top_srcdir)/ -I$(top_srcdir)/utils/ \ + -I$(top_srcdir)/rpc DISTCLEANFILES = Makefile.in diff --git a/cli/gluster-block.c b/cli/gluster-block.c index 129467d..d2ad4c2 100644 --- a/cli/gluster-block.c +++ b/cli/gluster-block.c @@ -11,6 +11,7 @@ # include "common.h" # include "block.h" +# include "config.h" @@ -21,6 +22,15 @@ typedef enum clioperations { DELETE_CLI = 4 } clioperations; +const char *argp_program_version = "" \ + PACKAGE_NAME" ("PACKAGE_VERSION")" \ + "\nRepository rev: https://github.com/pkalever/gluster-block.git\n" \ + "Copyright (c) 2016 Red Hat, Inc. \n" \ + "gluster-block comes with ABSOLUTELY NO WARRANTY.\n" \ + "It is licensed to you under your choice of the GNU Lesser\n" \ + "General Public License, version 3 or any later version (LGPLv3\n" \ + "or later), or the GNU General Public License, version 2 (GPLv2),\n"\ + "in all cases as published by the Free Software Foundation."; static int glusterBlockCliRPC_1(void *cobj, clioperations opt, char **out) @@ -129,22 +139,23 @@ static void glusterBlockHelp(void) { MSG("%s", - "gluster-block (Version 0.1) \n" - " create Create the gluster block\n" - " volserver [gluster-node] node addr from gluster pool(default: localhost)\n" + PACKAGE_NAME" ("PACKAGE_VERSION")\n" + "usage:\n" + " gluster-block [] \n" + "\n" + "commands and arguments:\n" + " create Create the gluster block\n" + " volserver node addr from gluster pool\n" " size block storage size in KiB|MiB|GiB|TiB..\n" - " mpath multipath requirement for high availability\n" + " [mpath ] multipath requirement for high availability(default: 1)\n" " servers block servers, where targets are exported\n" - "\n" - " list List available gluster blocks\n" - "\n" - " info Details about gluster block\n" - "\n" - " modify Modify the metadata\n" - "\n" - " delete Delete the gluster block\n" - "\n" - " volume gluster volume name\n" + " list List available gluster blocks\n" + " info Details about gluster block\n" + " modify Modify metadata\n" + " delete Delete gluster block\n" + " volume gluster volume name(must option for all)\n" + " help Show this message and exit\n" + " version Show version info and exit\n" ); } @@ -162,15 +173,18 @@ glusterBlockCreate(int argcount, char **options) if(argcount <= optind) { MSG("%s\n", "Insufficient arguments for create:"); - MSG("%s\n", "gluster-block create volume " - "volserver size mpath " - "servers "); + MSG("%s\n", "gluster-block create volume " + "volserver size [mpath ]" + " servers "); return -1; } /* name of block */ strcpy(cobj.block_name, options[optind++]); + /* default mpath */ + cobj.mpath = 1; + while (1) { if(argcount <= optind) { break; @@ -198,7 +212,6 @@ glusterBlockCreate(int argcount, char **options) case GB_CLI_CREATE_MULTIPATH: sscanf(options[optind++], "%u", &cobj.mpath); - ret++; break; case GB_CLI_CREATE_SIZE: @@ -228,11 +241,11 @@ glusterBlockCreate(int argcount, char **options) } /* check all options required by create command are specified */ - if(ret < 4) { + if(ret < 3) { MSG("%s\n", "Insufficient arguments for create:"); - MSG("%s\n", "gluster-block create volume " - "volserver size mpath " - "servers "); + MSG("%s\n", "gluster-block create volume " + "volserver size [mpath ]" + " servers "); ret = -1; goto out; } @@ -267,7 +280,7 @@ glusterBlockList(int argcount, char **options) if(argcount <= optind) { MSG("%s\n", "Insufficient arguments for list:"); - MSG("%s\n", "gluster-block list volume "); + MSG("%s\n", "gluster-block list volume "); return -1; } @@ -307,7 +320,7 @@ glusterBlockDelete(int argcount, char **options) if(argcount <= optind) { MSG("%s\n", "Insufficient arguments for delete:"); - MSG("%s\n", "gluster-block delete volume "); + MSG("%s\n", "gluster-block delete volume "); return -1; } @@ -349,7 +362,7 @@ glusterBlockInfo(int argcount, char **options) if(argcount <= optind) { MSG("%s\n", "Insufficient arguments for info:"); - MSG("%s\n", "gluster-block info volume "); + MSG("%s\n", "gluster-block info volume "); return -1; } @@ -429,6 +442,10 @@ glusterBlockParseArgs(int count, char **options) case GB_CLI_HELP: glusterBlockHelp(); goto out; + + case GB_CLI_VERSION: + MSG("%s\n", argp_program_version); + goto out; } } -- cgit