mirror of
https://github.com/chubin/cheat.sh.git
synced 2026-06-20 21:26:44 +02:00
Enable action=suggest
This commit is contained in:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user