瀏覽代碼

db.login: implement print flag

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@60472 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 11 年之前
父節點
當前提交
dde4dc704c
共有 1 個文件被更改,包括 12 次插入0 次删除
  1. 12 0
      db/db.login/main.c

+ 12 - 0
db/db.login/main.c

@@ -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 @@ int main(int argc, char *argv[])
     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"));