1
0
mirror of https://github.com/chubin/cheat.sh.git synced 2026-06-20 13:16:44 +02:00

Enable action=suggest

This commit is contained in:
Igor Chubin
2021-02-06 08:18:17 +01:00
parent e70b815306
commit 447a714a3f
+8
View File
@@ -39,6 +39,8 @@ If the problem persists, file a GitHub issue at
github.com/chubin/cheat.sh or ping @igor_chubin
"""
NOT_AUTHORIZED_MESSAGE = """403 UNAUTHORIZED"
class Question(UpstreamAdapter):
"""
@@ -111,6 +113,12 @@ class Question(UpstreamAdapter):
else:
topic = [topic]
if request_option.get("action") == "suggest":
if request_option.get("authorized"):
topic = ["--action", "suggest"] + topic
else:
return NOT_AUTHORIZED_MESSAGE
cmd = [CONFIG["path.internal.bin.upstream"]] + topic
proc = Popen(cmd, stdin=open(os.devnull, "r"), stdout=PIPE, stderr=PIPE)
answer = proc.communicate()[0].decode('utf-8')