This is the mail archive of the cygwin-apps@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Proposed patch - make longopts behave as newbies expect


The current setup.exe implementation does not handle longopts
in the way that a newbie would expect.  Specifically,
  setup.exe --root e:\foo
does not work; either
  setup.exe -R e:\foo      or
  setup.exe --root=e:\foo
is required.

This is because the --root, --site, and --override-registry-name
StringOptions use the default value that specifies that a value
is optional, which, imho, is wrong.

This patch corrects this, and adds a test program as well.


Cheers,

Jeremy



2003-07-10  Jeremy White  <jwhite@codeweavers.com>

	* mount.cc,root.cc,site.cc:  Make StringOptions required,
            thereby making --longopt <parm> behave as a newbie
            would expect.
	* libgetopt++/tests/teststring.cc:  Add a StringOption test.


? build
? config.log
? longopt.diff
? save
? libgetopt++/tests/teststring.cc
Index: mount.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/mount.cc,v
retrieving revision 2.15
diff -u -r2.15 mount.cc
--- mount.cc	15 Jan 2003 22:06:22 -0000	2.15
+++ mount.cc	10 Jul 2003 14:55:01 -0000
@@ -77,7 +77,7 @@
 #ifdef MAINTAINER_FEATURES
 #include "getopt++/GetOption.h"
 #include "getopt++/StringOption.h"
-static StringOption CygwinRegistryNameOption (CYGWIN_INFO_CYGWIN_REGISTRY_NAME, '#', "override-registry-name", "Override registry name to allow parallel installs for testing purposes");
+static StringOption CygwinRegistryNameOption (CYGWIN_INFO_CYGWIN_REGISTRY_NAME, '#', "override-registry-name", "Override registry name to allow parallel installs for testing purposes", false);
 #undef CYGWIN_INFO_CYGWIN_REGISTRY_NAME
 #define CYGWIN_INFO_CYGWIN_REGISTRY_NAME (((std::string)CygwinRegistryNameOption).c_str())
 #endif
Index: root.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/root.cc,v
retrieving revision 2.12
diff -u -r2.12 root.cc
--- root.cc	9 Nov 2002 13:44:54 -0000	2.12
+++ root.cc	10 Jul 2003 14:55:01 -0000
@@ -40,7 +40,7 @@
 
 using namespace std;
 
-StringOption RootOption ("", 'R', "root", "Root installation directory");
+StringOption RootOption ("", 'R', "root", "Root installation directory", false);
 
 static int rb[] = { IDC_ROOT_TEXT, IDC_ROOT_BINARY, 0 };
 static int su[] = { IDC_ROOT_SYSTEM, IDC_ROOT_USER, 0 };
Index: site.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/site.cc,v
retrieving revision 2.25
diff -u -r2.25 site.cc
--- site.cc	10 Mar 2003 08:50:16 -0000	2.25
+++ site.cc	10 Jul 2003 14:55:02 -0000
@@ -52,7 +52,7 @@
 SiteList site_list;
 SiteList all_site_list;
 
-StringOption SiteOption("", 's', "site", "Download site");
+StringOption SiteOption("", 's', "site", "Download site", false);
 
 /* XXX make into a singleton? */
 static SiteSetting ChosenSites;

===================================================================
--- /dev/null	2003-07-10 10:02:12.000000000 -0500
+++ libgetopt++/tests/teststring.cc	2003-07-10 09:52:06.000000000 -0500
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2002 Robert Collins.
+ * Copyright (c) 2003 Robert Collins.
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU General Public License as published by
+ *     the Free Software Foundation; either version 2 of the License, or
+ *     (at your option) any later version.
+ *
+ *     A copy of the GNU General Public License can be found at
+ *     http://www.gnu.org/
+ *
+ * Written by Robert Collins <robertc@hotmail.com>
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+
+#include "getopt++/GetOption.h"
+#include "getopt++/BoolOption.h"
+#include "getopt++/StringOption.h"
+
+#include <iostream>
+
+using namespace std;
+
+static BoolOption testoption (false, 't', "testoption", "Tests the use of boolean options");
+static BoolOption helpoption (false, 'h', "help", "Tests the use of help output.");
+static StringOption RootOption ("", 'R', "root", "Root installation directory", false);
+int
+main (int argc, char **argv)
+{
+    int i;
+
+  if (!GetOption::GetInstance().Process (argc, argv))
+    {
+      std::cout << "Failed to process options" << std::endl;
+      return 1;
+    }
+  if (helpoption)
+    {
+      GetOption::GetInstance().ParameterUsage(std::cout);
+    }
+  if (testoption)
+    {
+      std::cout << "Test Option used" << std::endl;
+    }
+  else
+    {
+      std::cout << "Test Option not used" << std::endl;
+    }
+
+    std::cout << "Root option is [" << (string)RootOption << "]" << endl;
+
+    return 0;
+}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]