; This file defines the external utilities that pgAdmin can execute from its
; Plugins menu. Utilities can be defined by specifying the following
; options for each.
;
; This file should be located alongside pgAdmin3.exe on Windows, and in the
; program data directory (normally called 'share') on Unix/OSX platforms.
;
; Title       - The title of the application to display on the menu
;
; Command     - The actual command to be executed. The following placeholders may
;               be used on the command line to insert context-specific information
;               into the command. Values may be empty if they are not relevant to 
;               the current object (e.g. $$TABLE will be empty if the selected
;               object is a database. Include quotes where they may be needed in
;               paths on Windows or appropriate escape characters on Mac/Unix.
;
;               $$HOSTNAME    - The server hostname (if known)
;               $$HOSTADDR    - The server address
;               $$PORT        - The port number used for the connection
;               $$SSLMODE     - The SSL mode used for the connection (defaults to
;                               'prefer' if unknown). Note that the PGSSLMODE 
;                               environment variable is also set.
;               $$DATABASE    - The current database name
;               $$USERNAME    - The username used to connect to the database
;               $$PASSWORD    - The password used to connect to the database (if 
;                               known)*
;               $$OBJECTNAME  - The name of the current object. This will be a
;                               * if an object collection is selected.
;               $$OBJECTTYPE  - A string describing the object type
;               $$SCHEMA      - The schema containing the current object. The
;                               same as $$OBJECTNAME if the current object is 
;                               a schema.
;               $$TABLE       - The table of which the current object is part
;                               The same as $$OBJECTNAME the current object is 
;                               a table
;               $$BINDIR      - The pgAdmin binary directory (i.e. where the 
;                               pgAdmin executable is found.
;               $$WORKINGDIR  - The current working directory.
;               $$PGBINDIR    - the PostgreSQL bin directory.
;               $$EDBBINDIR   - the EnterpriseDB bin directory.
;               $$SLONYBINDIR - the EnterpriseDB bin directory.
;
;               Commands containing spaces in paths should be appropriately
;               quoted.
;
; Description - A description of the utility for use in tooltips etc.
;
; KeyFile     - If specified, this file must exist for the plugin to be shown
;               on the menus. $$BINDIR, $$PGBINDIR, $$EDBBINDIR, $$SLONYBINDIR
;               and $$WORKINGDIR may be used in the KeyFile value.
;
; Platform    - If specified, targets the plugin to a specific platform. Must
;               be one of 'windows', 'unix' or 'osx'.
;
; Database    - Set to 'Yes' to indicate that the command needs to be executed
;               where database connection is possible - ie. when the currently
;               selected object in the treeview is a database or child object.
;
; AppliesTo   - A comma-delimited list of object type names that this plugin is
;               applicable to. Collections may also be specified, eg. Tables.
;               This test is logically ANDed with the Database option when
;               determining if a plugin applies to an object. If the option is
;               missing or empty, the plugin will be activated based only on
;               evaluation of its need for a database.
;
; ServerType  - A comma-delimited list of server types that this plugin is
;               applicable to. Valid server types are 'postgresql' and 
;               'enterprisedb'. This test is only applicable to plugins that
;               have Database=Yes set.
;
; SetPassword - Set to 'Yes' to set the PGPASSWORD environment variable, if the
;               password is known*
;
; * Note: Passing passwords via the command line or environment may be insecure
;         one some platforms. USE WITH CAUTION!!
;
; A new app is defined every time a Title or [Separator] option option is found,
; or the end of the file is reached. Subsequent options will apply to that
; application. If the same option is specified more than once for an utility,
; the last one will be used. The Title and Command for each utility must be
; specified.

;
; PSQL (Unix):
;
Title=PSQL Console
Command=/usr/bin/xterm -e "$$PGBINDIR/psql" --host "$$HOSTNAME" --port $$PORT --username "$$USERNAME" "$$DATABASE"
Description=Open a PSQL console to the current database.
KeyFile=$$PGBINDIR/psql
Platform=unix
ServerType=postgresql
Database=Yes
SetPassword=Yes
;
; PSQL (Windows):
;
Title=PSQL Console
Command="$$PGBINDIR\psql.exe" --host "$$HOSTNAME" --port $$PORT --username "$$USERNAME" "$$DATABASE"
Description=Open a PSQL console to the current database.
KeyFile=$$PGBINDIR\psql.exe
Platform=windows
ServerType=postgresql
Database=Yes
SetPassword=Yes
;
; PSQL (OSX):
;
Title=PSQL Console
Command=/usr/bin/osascript -e 'ignoring application responses' -e 'tell application "Terminal"' -e 'activate' -e 'do script with command "\'$$PGBINDIR/psql\' --host \'$$HOSTNAME\' --port $$PORT --username \'$$USERNAME\' \'$$DATABASE\' && exit || sleep 5 && exit"' -e 'end tell' -e 'end ignoring'
Description=Open a PSQL console to the current database.
KeyFile=$$PGBINDIR/psql
Platform=osx
ServerType=postgresql
Database=Yes
SetPassword=Yes

;
; EDB PSQL (Unix):
;
Title=EDB-PSQL Console
Command=/usr/bin/xterm -e "$$EDBBINDIR/edb-psql" --host "$$HOSTNAME" --port $$PORT --username "$$USERNAME" "$$DATABASE"
Description=Open a EDB-PSQL console to the current database.
KeyFile=$$EDBBINDIR/edb-psql
Platform=unix
ServerType=enterprisedb
Database=Yes
SetPassword=Yes
;
; PSQL (Windows):
;
Title=EDB-PSQL Console
Command="$$EDBBINDIR\edb-psql.exe" --host "$$HOSTNAME" --port $$PORT --username "$$USERNAME" "$$DATABASE"
Description=Open a EDB-PSQL console to the current database.
KeyFile=$$EDBBINDIR\edb-psql.exe
Platform=windows
ServerType=enterprisedb
Database=Yes
SetPassword=Yes
;


;
; PostGIS shp2pgsql-gui (Windows):
;
Title=PostGIS Shapefile and DBF loader
Command="$$PGBINDIR\postgisgui\shp2pgsql-gui.exe" -h "$$HOSTNAME" -p $$PORT -U "$$USERNAME" -d "$$DATABASE" -W "$$PASSWORD"
Description=Open a PostGIS ESRI Shapefile or Plain dbf loader console to the current database.
KeyFile=$$PGBINDIR\postgisgui\shp2pgsql-gui.exe
Platform=windows
ServerType=postgresql
Database=Yes
SetPassword=Yes

; PSQL (OSX):
;
Title=EDB-PSQL Console
Command=/usr/bin/osascript -e 'ignoring application responses' -e 'tell application "Terminal"' -e 'activate' -e 'do script with command "\'$$EDBBINDIR/edb-psql\' --host \'$$HOSTNAME\' --port $$PORT --username \'$$USERNAME\' \'$$DATABASE\' && exit || sleep 5 && exit"' -e 'end tell' -e 'end ignoring'
Description=Open a EDB-PSQL console to the current database.
KeyFile=$$EDBBINDIR/edb-psql
Platform=osx
ServerType=enterprisedb
Database=Yes
SetPassword=Yes

; 
; The following example shows how we might add a separator and additional plugin
;
; [Separator]
;
; Title=Quick backup
; Command=/usr/bin/xterm -e "$$PGBINDIR/pg_dump" --host "$$HOSTNAME" --port $$PORT --username "$$USERNAME" "$$DATABASE" > ~/db-`date +%Y%m%d%H%m`.bak
; Description=Perform a quick backup of the current database.
; KeyFile=$$PGBINDIR/pg_dump
; Platform=unix
; ServerType=postgresql
; Database=Yes
; AppliesTo=database
; SetPassword=Yes

