[GRASS-SVN] r60472 - grass/trunk/db/db.login

svn_grass at osgeo.org svn_grass at osgeo.org
Sun May 25 01:55:14 PDT 2014


Author: martinl
Date: 2014-05-25 01:55:14 -0700 (Sun, 25 May 2014)
New Revision: 60472

Modified:
   grass/trunk/db/db.login/main.c
Log:
db.login: implement print flag

Modified: grass/trunk/db/db.login/main.c
===================================================================
--- grass/trunk/db/db.login/main.c	2014-05-25 08:54:54 UTC (rev 60471)
+++ grass/trunk/db/db.login/main.c	2014-05-25 08:55:14 UTC (rev 60472)
@@ -30,6 +30,7 @@
 int main(int argc, char *argv[])
 {
     struct Option *driver, *database, *user, *password;
+    struct Flag *print;
     struct GModule *module;
     
     /* Initialize the GIS calls */
@@ -65,9 +66,20 @@
     password->description = _("Password to set for DB connection");
     password->guisection = _("Settings");
 
+    print = G_define_flag();
+    print->key = 'p';
+    print->description = _("Print connection settings and exit");
+    print->guisection = _("Print");
+    
     if (G_parser(argc, argv))
         exit(EXIT_FAILURE);
 
+    if (print->answer) {
+        /* print all settings to standard output and exit */
+        db_get_login_dump(stdout);
+        exit(EXIT_SUCCESS);
+    }
+
     if (db_set_login(driver->answer, database->answer, user->answer,
                      password->answer) == DB_FAILED) {
         G_fatal_error(_("Unable to set user/password"));



More information about the grass-commit mailing list