Skip to content

Commit

Permalink
Display all connections when query is empty
Browse files Browse the repository at this point in the history
Made the search argument optional, and updated the script to return
all connections when no argument is provided.
Changed input from `{query}` to `argv` to support special characters.
  • Loading branch information
sbine committed Sep 19, 2019
1 parent dc12975 commit f2a843a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions info.plist
Expand Up @@ -60,10 +60,12 @@
<false/>
<key>alfredfiltersresultsmatchmode</key>
<integer>0</integer>
<key>argumenttreatemptyqueryasnil</key>
<false/>
<key>argumenttrimmode</key>
<integer>0</integer>
<key>argumenttype</key>
<integer>0</integer>
<integer>1</integer>
<key>escaping</key>
<integer>127</integer>
<key>keyword</key>
Expand All @@ -79,9 +81,9 @@
<key>runningsubtext</key>
<string>Searching connections for "{query}"...</string>
<key>script</key>
<string>php tableplus.php "{query}"</string>
<string>php tableplus.php "$1"</string>
<key>scriptargtype</key>
<integer>0</integer>
<integer>1</integer>
<key>scriptfile</key>
<string></string>
<key>subtext</key>
Expand All @@ -98,7 +100,7 @@
<key>uid</key>
<string>7B86D057-DA8E-4302-AF17-83B889B48EE2</string>
<key>version</key>
<integer>2</integer>
<integer>3</integer>
</dict>
</array>
<key>readme</key>
Expand Down
2 changes: 1 addition & 1 deletion tableplus.php
Expand Up @@ -21,7 +21,7 @@
$connections = $plist->plistToArray(file_exists($setapp_connections_path) ? $setapp_connections_path : $default_connections_path);
$groups = $plist->plistToArray(file_exists($setapp_groups_path) ? $setapp_groups_path : $default_groups_path);

$results = array_filter($connections, function ($connection) use ($query) {
$results = empty($query) ? $connections : array_filter($connections, function ($connection) use ($query) {
return strpos(strtolower($connection['ConnectionName']), strtolower($query)) !== false;
});

Expand Down

0 comments on commit f2a843a

Please sign in to comment.