Skip to content

Commit

Permalink
back to search button when no match
Browse files Browse the repository at this point in the history
  • Loading branch information
yinan-c committed Jun 1, 2023
1 parent c694202 commit a15458f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 16 deletions.
27 changes: 25 additions & 2 deletions info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@
<integer>1</integer>
<key>escaping</key>
<integer>102</integer>
<key>keyword</key>
<string>{var:info_key}</string>
<key>queuedelaycustom</key>
<integer>3</integer>
<key>queuedelayimmediatelyinitially</key>
Expand All @@ -225,7 +227,7 @@ python3 runcommands.py "$1"</string>
<key>type</key>
<integer>5</integer>
<key>withspace</key>
<false/>
<true/>
</dict>
<key>type</key>
<string>alfred.workflow.input.scriptfilter</string>
Expand Down Expand Up @@ -896,7 +898,7 @@ More detailed README with figures can be found on [GitHub](https://github.com/yi
<key>56DD91CF-0600-483C-8D9A-FEA93162B9D8</key>
<dict>
<key>note</key>
<string>`Enter` on search results to get info and commands</string>
<string>Search results to get info and commands</string>
<key>xpos</key>
<real>410</real>
<key>ypos</key>
Expand Down Expand Up @@ -1083,6 +1085,27 @@ More detailed README with figures can be found on [GitHub](https://github.com/yi
<key>variable</key>
<string>leaves_key</string>
</dict>
<dict>
<key>config</key>
<dict>
<key>default</key>
<string>info</string>
<key>placeholder</key>
<string></string>
<key>required</key>
<false/>
<key>trim</key>
<true/>
</dict>
<key>description</key>
<string>Check the status/commands of a certain formula/cask</string>
<key>label</key>
<string>Show status and commands keyword</string>
<key>type</key>
<string>textfield</string>
<key>variable</key>
<string>info_key</string>
</dict>
</array>
<key>version</key>
<string>1.1.1</string>
Expand Down
28 changes: 14 additions & 14 deletions runcommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,21 +142,21 @@ def get_commands(brewtype,formula_name):

if __name__ == '__main__':
output_data = {"items": []}
if sys.argv[1] == '':
output_data = {
"items": [
{
"title": "Back to search",
"arg": 1,
"icon": {"path": "icons/back.png"},
"valid": True
}
]}
else:
try:
output_data = get_commands('cask',sys.argv[1])
output_data['items'].extend(get_info('cask',sys.argv[1])['items'])
except:
try:
output_data = get_commands('cask',sys.argv[1])
output_data['items'].extend(get_info('cask',sys.argv[1])['items'])
except:
output_data = get_commands('formula',sys.argv[1])
output_data['items'].extend(get_info('formula',sys.argv[1])['items'])
except:
output_data = {
"items": [
{
"title": "No cask/formula found, back to search",
"arg": 1,
"icon": {"path": "icons/back.png"},
"valid": True
}
]}
print(json.dumps(output_data))

0 comments on commit a15458f

Please sign in to comment.