Skip to content

Commit

Permalink
feat: added autocomplete with TAB
Browse files Browse the repository at this point in the history
  • Loading branch information
Datalux committed Sep 5, 2020
1 parent 301bda6 commit 07e0fe8
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
from src import printcolors as pc
import sys
import signal
import readline

commands = ["quit", "exit", "list", "help", "addrs", "captions", "comments", "followers",
"followings", "fwersemail", "fwingsemail", "hashtags", "info", "likes",
"mediatype", "photodes", "photos", "propic", "stories", "tagged", "target",
"wcommented", "wtagged"]


def printlogo():
Expand Down Expand Up @@ -75,7 +81,17 @@ def signal_handler(sig, frame):
sys.exit(0)


def completer(text, state):
options = [i for i in commands if i.startswith(text)]
if state < len(options):
return options[state]
else:
return None


signal.signal(signal.SIGINT, signal_handler)
readline.parse_and_bind("tab: complete")
readline.set_completer(completer)

printlogo()

Expand Down

0 comments on commit 07e0fe8

Please sign in to comment.