SVN Commit by dpage: r4884 - in trunk/pgadmin3: . docs/en_US src src/frm src/include

From: svn(at)pgadmin(dot)org
To: pgadmin-hackers(at)postgresql(dot)org
Subject: SVN Commit by dpage: r4884 - in trunk/pgadmin3: . docs/en_US src src/frm src/include
Date: 2006-01-09 10:38:50
Message-ID: 200601091038.k09AcoLu023182@developer.pgadmin.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-hackers

Author: dpage
Date: 2006-01-09 10:38:49 +0000 (Mon, 09 Jan 2006)
New Revision: 4884

Added:
trunk/pgadmin3/docs/en_US/commandline.html
Modified:
trunk/pgadmin3/CHANGELOG.txt
trunk/pgadmin3/docs/en_US/pgadmin3.hhc
trunk/pgadmin3/docs/en_US/pgadmin3.hhp.cached
trunk/pgadmin3/docs/en_US/using.html
trunk/pgadmin3/src/frm/frmMain.cpp
trunk/pgadmin3/src/include/frmMain.h
trunk/pgadmin3/src/pgAdmin3.cpp
Log:
Add -a and -q command line options to auto connect to a server and open a query window respectively [Magnus Hagander]

Modified: trunk/pgadmin3/CHANGELOG.txt
===================================================================
--- trunk/pgadmin3/CHANGELOG.txt 2006-01-09 09:31:15 UTC (rev 4883)
+++ trunk/pgadmin3/CHANGELOG.txt 2006-01-09 10:38:49 UTC (rev 4884)
@@ -18,6 +18,7 @@
</ul>
<br>
<ul>
+ <li>2006-01-09 DP Add -a and -q command line options to auto connect to a server and open a query window respectively [Magnus Hagander]
<li>2006-01-09 DP 1.4.2 Honour the copy quoting setting properly in the SQL results pane [Magnus Hagander]
<li>2006-01-09 DP Use Ctrl-A to select all results in the query results pane. [Magnus Hagander]
<li>2006-01-09 DP 1.4.2 Set the initial Unicode/Local charset options correctly in the Export dialogue [Magnus Hagander]

Added: trunk/pgadmin3/docs/en_US/commandline.html
===================================================================
--- trunk/pgadmin3/docs/en_US/commandline.html 2006-01-09 09:31:15 UTC (rev 4883)
+++ trunk/pgadmin3/docs/en_US/commandline.html 2006-01-09 10:38:49 UTC (rev 4884)
@@ -0,0 +1,40 @@
+<html>
+
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
+<link rel="STYLESHEET" type="text/css" href="pgadmin3.css">
+<title>Command Line Parameters</title>
+</head>
+
+<body>
+
+<h3>Command Line Parameters</h3>
+<p>
+There are a number of command line options that may be passed to the pgAdmin executable
+when starting it.
+</p>
+
+<ul>
+ <li><b>-h</b> Display command line option help.<br />&nbsp;</li>
+
+ <li><b>-s &lt;server description&gt;</b> Auto connect to the specified server. &lt;server description&gt; is the description
+ entered when you added the server to the treeview in pgAdmin, quoted if required. If multiple servers are registered with
+ the same description, the first found will be auto-connected.<br />&nbsp;</li>
+
+ <li><b>-q</b> Open a <a href="query.html">Query Tool</a> window upon connection. This option requires the
+ <b>-s &lt;server description&gt;</b> option.<br />&nbsp;</li>
+
+ <li><b>-cm &lt;config file&gt;</b> Edit the specified postgresql.conf config file.<br />&nbsp;</li>
+
+ <li><b>-ch &lt;hba file&gt;</b> Edit the specified pg_hba.conf config file.<br />&nbsp;</li>
+
+ <li><b>-c &lt;file&gt;</b> Edit the specified config file. pgAdmin will attempt to auto-detect what type of config file is
+ being editted.<br />&nbsp;</li>
+
+ <li><b>-t</b> Start in dialogue translation test mode. This mode allows each dialogue to be viewed without running the
+ application to assist with string translation.<br />&nbsp;</li>
+</ul>
+
+</body>
+
+</html>

Modified: trunk/pgadmin3/docs/en_US/pgadmin3.hhc
===================================================================
--- trunk/pgadmin3/docs/en_US/pgadmin3.hhc 2006-01-09 09:31:15 UTC (rev 4883)
+++ trunk/pgadmin3/docs/en_US/pgadmin3.hhc 2006-01-09 10:38:49 UTC (rev 4884)
@@ -106,6 +106,10 @@
<param name="Name" value="Guru Hints">
<param name="Local" value="guruhints.html">
</OBJECT>
+ <LI> <OBJECT type="text/sitemap">
+ <param name="Name" value="Command Line Options">
+ <param name="Local" value="commandline.html">
+ </OBJECT>
</UL>
<LI> <OBJECT type="text/sitemap">
<param name="Name" value="pgAgent">

Modified: trunk/pgadmin3/docs/en_US/pgadmin3.hhp.cached
===================================================================
(Binary files differ)

Modified: trunk/pgadmin3/docs/en_US/using.html
===================================================================
--- trunk/pgadmin3/docs/en_US/using.html 2006-01-09 09:31:15 UTC (rev 4883)
+++ trunk/pgadmin3/docs/en_US/using.html 2006-01-09 10:38:49 UTC (rev 4884)
@@ -10,7 +10,7 @@

<H3>Using pgAdmin</H3>
<P>This section explains how you can use pgAdmin to maintain your
-PostgreSQL databases. PgAdmin supports database server versions
+PostgreSQL databases. pgAdmin supports database server versions
7.3 and up. Versions older than 7.3 are not supported, please use
pgAdmin II for these.</P>
<UL>
@@ -44,6 +44,7 @@
<LI><P>The <A HREF="options.html">Options</A> dialogue will allow
you to configure pgAdmin.</P>
<LI><P><A HREF="guruhints.html">Guru Hints</A> help you perfect your databases.</P>
+ <LI><P><A HREF="commandline.html">Command Line Options</A> to start pgAdmin in the most convenient mode.</P>
</UL>
<P>When editing the properties of a database object, pgAdmin will
support you with help about the underlying PostgreSQL SQL commands,

Modified: trunk/pgadmin3/src/frm/frmMain.cpp
===================================================================
--- trunk/pgadmin3/src/frm/frmMain.cpp 2006-01-09 09:31:15 UTC (rev 4883)
+++ trunk/pgadmin3/src/frm/frmMain.cpp 2006-01-09 10:38:49 UTC (rev 4884)
@@ -630,7 +630,7 @@
}


-int frmMain::ReconnectServer(pgServer *server)
+int frmMain::ReconnectServer(pgServer *server, bool restore)
{
// Create a server object and connect it.
wxBusyInfo waiting(wxString::Format(_("Connecting to server %s (%s:%d)"),
@@ -644,26 +644,29 @@
{
case PGCONN_OK:
{
- StartMsg(_("Restoring previous environment"));
- wxLogInfo(wxT("pgServer object initialised as required."));
+ if (restore)
+ {
+ StartMsg(_("Restoring previous environment"));
+ wxLogInfo(wxT("pgServer object initialised as required."));

- server->ShowTreeDetail(browser);
- browser->Freeze();
- item=RestoreEnvironment(server);
- browser->Thaw();
+ server->ShowTreeDetail(browser);
+ browser->Freeze();
+ item=RestoreEnvironment(server);
+ browser->Thaw();

- if (item)
- {
- browser->SelectItem(item);
+ if (item)
+ {
+ browser->SelectItem(item);

- wxSafeYield();
- browser->Expand(item);
- browser->EnsureVisible(item);
- }
- if (item)
- EndMsg(true);
- else
- EndMsg(false);
+ wxSafeYield();
+ browser->Expand(item);
+ browser->EnsureVisible(item);
+ }
+ if (item)
+ EndMsg(true);
+ else
+ EndMsg(false);
+ }
return res;
}
case PGCONN_DNSERR:
@@ -797,6 +800,24 @@
browser->SetItemText(serversObj->GetId(), label);
}

+pgServer *frmMain::ConnectToServer(const wxString& servername, bool restore)
+{
+ for (int i = 0; ; i++)
+ {
+ pgObject *o = serversObj->FindChild(browser, i);
+ if (!o)
+ return NULL;
+ if (o->IsCreatedBy(serverFactory))
+ {
+ pgServer *s = (pgServer *)o;
+ if (s->GetDescription() == servername)
+ {
+ ReconnectServer(s, restore);
+ return s;
+ }
+ }
+ }
+}

void frmMain::StartMsg(const wxString& msg)
{

Modified: trunk/pgadmin3/src/include/frmMain.h
===================================================================
--- trunk/pgadmin3/src/include/frmMain.h 2006-01-09 09:31:15 UTC (rev 4883)
+++ trunk/pgadmin3/src/include/frmMain.h 2006-01-09 10:38:49 UTC (rev 4884)
@@ -59,9 +59,10 @@
ctlListView *GetDependsOn();
ctlListView *GetReferencedBy();
void StoreServers();
- int ReconnectServer(pgServer *server);
+ int ReconnectServer(pgServer *server, bool restore = true);
void ReportConnError(pgServer *server);
pgServerCollection *GetServerCollection() { return serversObj; }
+ pgServer *ConnectToServer(const wxString& servername, bool restore = false);

private:
ctlTree *browser;

Modified: trunk/pgadmin3/src/pgAdmin3.cpp
===================================================================
--- trunk/pgadmin3/src/pgAdmin3.cpp 2006-01-09 09:31:15 UTC (rev 4883)
+++ trunk/pgadmin3/src/pgAdmin3.cpp 2006-01-09 10:38:49 UTC (rev 4884)
@@ -15,6 +15,7 @@
// wxWindows headers
#include <wx/wx.h>
#include <wx/app.h>
+#include <wx/cmdline.h>
#include <wx/dir.h>
#include <wx/file.h>
#include <wx/xrc/xmlres.h>
@@ -170,35 +171,46 @@
// The Application!
bool pgAdmin3::OnInit()
{
+ static const wxCmdLineEntryDesc cmdLineDesc[] =
+ {
+ {wxCMD_LINE_SWITCH, wxT("h"), wxT("help"), wxT("show this help message"), wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP },
+ {wxCMD_LINE_OPTION, wxT("s"), wxT("server"), wxT("auto-connect to specified server"), wxCMD_LINE_VAL_STRING},
+ {wxCMD_LINE_SWITCH, wxT("q"), wxT("query"), wxT("open query tool to auto-connected server"), wxCMD_LINE_VAL_NONE},
+ {wxCMD_LINE_OPTION, wxT("cm"), NULL, wxT("edit main configuration file"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_MULTIPLE},
+ {wxCMD_LINE_OPTION, wxT("ch"), NULL, wxT("edit HBA configuration file"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_MULTIPLE},
+ {wxCMD_LINE_OPTION, wxT("c"), NULL, wxT("edit any configuration file"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_MULTIPLE},
+ {wxCMD_LINE_SWITCH, wxT("t"), NULL, wxT("dialog translation test mode"), wxCMD_LINE_VAL_NONE},
+ {wxCMD_LINE_NONE}
+ };
+
+
// we are here
InitPaths();

frmConfig::tryMode configMode=frmConfig::NONE;
+ wxString configFile;

- if (argc > 1 && *argv[1] == '-')
- {
- switch (argv[1][1])
- {
- case 'c':
- {
- // file configurator mode
- if (argv[1][2]== 'm')
- configMode = frmConfig::MAINFILE;
- else if (argv[1][2]== 'h')
- configMode = frmConfig::HBAFILE;
- else
- configMode=frmConfig::ANYFILE;
+ wxCmdLineParser cmdParser(cmdLineDesc, argc, argv);
+ if (cmdParser.Parse() != 0)
+ return false;

- break;
- }
- case 't':
- {
- dialogTestMode = true;
- break;
- }
- }
- }
+ if (cmdParser.Found(wxT("q")) && !cmdParser.Found(wxT("s")))
+ {
+ cmdParser.Usage();
+ return false;
+ }
+
+ if (cmdParser.Found(wxT("cm"), &configFile))
+ configMode = frmConfig::MAINFILE;
+ else if (cmdParser.Found(wxT("ch"), &configFile))
+ configMode = frmConfig::HBAFILE;
+ else if (cmdParser.Found(wxT("c"), &configFile))
+ configMode = frmConfig::ANYFILE;

+ if (cmdParser.Found(wxT("t")))
+ dialogTestMode = true;
+
+
// evaluate all working paths

#if defined(__WXMSW__)
@@ -351,29 +363,15 @@

if (configMode)
{
- int i;
-
- for (i=2 ; i < argc ; i++)
- {
- wxString str;
- if (*argv[i] == '"')
- {
- wxString str=argv[i]+1;
- str=str.Mid(0, str.Length()-1);
- }
- else
- str = argv[i];
-
- if (configMode == frmConfig::ANYFILE && wxDir::Exists(str))
- {
- frmConfig::Create(APPNAME_L, str + wxT("/pg_hba.conf"), frmConfig::HBAFILE);
- frmConfig::Create(APPNAME_L, str + wxT("/postgresql.conf"), frmConfig::MAINFILE);
- }
- else
- {
- frmConfig::Create(APPNAME_L, str, configMode);
- }
- }
+ if (configMode == frmConfig::ANYFILE && wxDir::Exists(configFile))
+ {
+ frmConfig::Create(APPNAME_L, configFile + wxT("/pg_hba.conf"), frmConfig::HBAFILE);
+ frmConfig::Create(APPNAME_L, configFile + wxT("/postgresql.conf"), frmConfig::MAINFILE);
+ }
+ else
+ {
+ frmConfig::Create(APPNAME_L, configFile, configMode);
+ }
if (winSplash)
{
winSplash->Close();
@@ -413,6 +411,17 @@
delete winSplash;
}

+ wxString str;
+ if (cmdParser.Found(wxT("s"), &str))
+ {
+ pgServer *srv = winMain->ConnectToServer(str, !cmdParser.Found(wxT("q")));
+ if (srv && cmdParser.Found(wxT("q")))
+ {
+ frmQuery *fq = new frmQuery(winMain, wxEmptyString, srv->CreateConn(), wxString(wxT("")));
+ fq->Go();
+ }
+ }
+
// Display a Tip if required.
extern sysSettings *settings;
wxCommandEvent evt = wxCommandEvent();

Responses

Browse pgadmin-hackers by date

  From Date Subject
Next Message Dave Page 2006-01-09 10:40:39 Re: Patch: commandline connect/launch
Previous Message Magnus Hagander 2006-01-09 10:01:04 Paste bug in Query Tool