From d1f3e15b0a13bf4946795e441221f01bd754daaf Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sun, 14 May 2023 18:00:35 +0100 Subject: [PATCH] Add command to test matching --- krunner_vscode/__main__.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/krunner_vscode/__main__.py b/krunner_vscode/__main__.py index ab944df..d821803 100755 --- a/krunner_vscode/__main__.py +++ b/krunner_vscode/__main__.py @@ -2,6 +2,8 @@ import difflib import json import os import sqlite3 +import sys +from operator import attrgetter from pathlib import Path from typing import NamedTuple @@ -115,6 +117,16 @@ class Runner(dbus.service.Object): os.system("xdg-open " + data) -runner = Runner() -loop = GLib.MainLoop() -loop.run() +def main(): + runner = Runner() + if sys.argv[1:]: + # Manual search - useful for local testing + for match in sorted(runner.Match(sys.argv[1]), key=attrgetter("relevance")): + print(match.data, match.relevance) + else: + loop = GLib.MainLoop() + loop.run() + + +if __name__ == "__main__": + main()