[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/koffice/1.6/koffice/kexi/kexidb
From: Jaroslaw Staniek <js () iidea ! pl>
Date: 2006-09-14 11:24:18
Message-ID: 1158233058.509008.15791.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 584223 by staniek:
KexiDB
- more options
2.0: merged
M +8 -0 global.h
M +22 -2 simplecommandlineapp.cpp
M +6 -5 simplecommandlineapp.h
--- branches/koffice/1.6/koffice/kexi/kexidb/global.h #584222:584223
@@ -159,4 +159,12 @@
}
+#ifndef futureI18n
+# define futureI18n QString
#endif
+
+#ifndef FUTURE_I18N_NOOP
+# define FUTURE_I18N_NOOP(x) (x)
+#endif
+
+#endif
--- branches/koffice/1.6/koffice/kexi/kexidb/simplecommandlineapp.cpp #584222:584223
@@ -22,6 +22,7 @@
#include <qfileinfo.h>
#include <kcmdlineargs.h>
+#include <kdebug.h>
#include <kexidb/connectiondata.h>
#include <kexidb/drivermanager.h>
@@ -30,10 +31,16 @@
static KCmdLineOptions predefinedOptions[] =
{
- { "drv <name>", FUTURE_I18N_NOOP("Database driver name"), 0 },
+ { "drv", 0, 0 },
+ { "driver <name>", FUTURE_I18N_NOOP("Database driver name"), 0 },
+ { "u", 0, 0 },
{ "user <name>", FUTURE_I18N_NOOP("Database user name"), 0 },
+ { "p", 0, 0 },
+ { "password", FUTURE_I18N_NOOP("Prompt for password"), 0 },
+ { "h", 0, 0 },
{ "host <name>", FUTURE_I18N_NOOP("Server (host) name"), 0 },
{ "port <number>", FUTURE_I18N_NOOP("Server's port number"), 0 },
+ { "s", 0, 0 },
{ "local-socket <filename>", FUTURE_I18N_NOOP("Server's local socket filename, if needed"), 0 },
KCmdLineLastOption
};
@@ -120,12 +127,25 @@
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
- d->connData.driverName = args->getOption("drv");
+ d->connData.driverName = args->getOption("driver");
d->connData.userName = args->getOption("user");
d->connData.hostName = args->getOption("host");
d->connData.localSocketFileName = args->getOption("local-socket");
d->connData.port = args->getOption("port").toInt();
d->connData.useLocalSocketFile = args->isSet("local-socket");
+
+ if (args->isSet("password")) {
+ QString userAtHost = d->connData.userName;
+ if (!d->connData.userName.isEmpty())
+ userAtHost += "@";
+ userAtHost += (d->connData.hostName.isEmpty() ? "localhost" : d->connData.hostName);
+ QTextStream cout(stdout,IO_WriteOnly);
+ cout << futureI18n("Enter password for %1: ").arg(userAtHost);
+//! @todo make use of pty/tty here! (and care about portability)
+ QTextStream cin(stdin,IO_ReadOnly);
+ cin >> d->connData.password;
+ KexiDBDbg << d->connData.password << endl;
+ }
}
SimpleCommandLineApp::~SimpleCommandLineApp()
--- branches/koffice/1.6/koffice/kexi/kexidb/simplecommandlineapp.h #584222:584223
@@ -31,12 +31,13 @@
{
//! @short A skeleton for creating a simple command line database application.
/*! This class creates a KInstance object and automatically handles the following
- command line arguments:
- - --drv <name> (Database driver name)
- - --user <name> (Database user name)
- - --host <name> (Server (host) name)
+ command line options:
+ - --driver <name> (Database driver name) or -drv
+ - --user <name> (Database user name) or -u
+ - --password (Prompt for password) or -p
+ - --host <name> (Server (host) name) or -h
- --port <number> (Server's port number)
- - --local-socket <filename> (Server's local socket filename, if needed)
+ - --local-socket <filename> (Server's local socket filename, if needed) or -s
You can use this helper class to create test applications or small tools that open
a KexiDB-compatible database using command line arguments, do some data processing
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic