added '--help' and '--version'
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Tue, 4 Nov 2003 13:50:48 +0000 (13:50 +0000)
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Tue, 4 Nov 2003 13:50:48 +0000 (13:50 +0000)
git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@370 94cd875c-1c1d-0410-91d2-eb244daf1a30

util-vserver/tests/vserver-info.c

index 0204958..46dd587 100644 (file)
 #include "src/util.h"
 #include <stdlib.h>
 
+static void
+checkArgs(int argc, char *argv[])
+{
+  if (argc==2) {
+    if (strcmp(argv[1], "--help")==0) {
+      WRITE_MSG(1, "Usage: vserver-info <vserver>\n");
+      exit(0);
+    }
+    if (strcmp(argv[1], "--version")==0) {
+      WRITE_MSG(1, "vserver-info " VERSION "\n");
+      exit(0);
+    }
+  }
+  else {
+    WRITE_MSG(2, "No vserver specified; try '--help' for more inforamtion\n");
+    exit(1);
+  }
+}
+
 int
 main(int argc, char *argv[])
 {
-  vcCfgStyle   style = vc_getVserverCfgStyle(argv[1]);
+  vcCfgStyle   style = (checkArgs(argc, argv), vc_getVserverCfgStyle(argv[1]));
   char const * name  = vc_getVserverName(argv[1], style);
   char const * vdir  = vc_getVserverVdir(argv[1], style);