Skip to content

Instantly share code, notes, and snippets.

@kamilion
Created March 13, 2020 07:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kamilion/c59285a4aa0ac9de23a86c7af2b11694 to your computer and use it in GitHub Desktop.
Save kamilion/c59285a4aa0ac9de23a86c7af2b11694 to your computer and use it in GitHub Desktop.
hooky, a really terrible package manager shell.
#!/usr/bin/python3
__author__="Kamilion@gmail.com"
import simpleeval
import apt
import readline
import os
import atexit
HISTFILE = os.path.join(os.environ["HOME"], ".hooky", ".hooky-history")
def update_repos():
print("Updating repositories")
def install(package):
print("Installing " + package)
pkg = cache[package]
pkg.mark_install()
res = cache.commit(fprogress, iprogress)
def remove(package):
print("Removing " + package)
pkg = cache[package]
pkg.mark_delete()
res = cache.commit(fprogress, iprogress)
def purge(package):
print("Purging " + package)
pkg = cache[package]
pkg.mark_delete(True)
res = cache.commit(fprogress, iprogress)
def main():
try:
readline.read_history_file(HISTFILE)
except IOError:
pass
readline.parse_and_bind('tab: complete')
commander = simpleeval.SimpleEval()
commander.functions["update"] = update_repos
commander.functions["install"] = install
commander.functions["remove"] = remove
commander.functions["purge"] = purge
while True:
command_line = input("hooky> ")
if command_line in "exit quit bye".split():
return
if command_line:
try:
commander.eval(command_line)
except simpleeval.FunctionNotDefined:
print("I don't know that token.")
cache = apt.Cache(apt.progress.text.OpProgress())
fprogress = apt.progress.text.AcquireProgress()
iprogress = apt.progress.base.InstallProgress()
if __name__ == "__main__":
try:
main()
except EOFError:
print()
atexit.register(readline.write_history_file, HISTFILE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment