-
-
Save omicronns/b7c9b891e4ef4d7c606c128c06678d68 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/env python3 | |
| import imp | |
| import sys | |
| import click | |
| import colorama | |
| import requests | |
| PKGM_VERSION = "1" | |
| class log: | |
| @staticmethod | |
| def err(msg): | |
| click.echo(click.style("[err] {}".format(msg), fg="red")) | |
| @staticmethod | |
| def wrn(msg): | |
| click.echo(click.style("[wrn] {}".format(msg), fg="yellow")) | |
| @staticmethod | |
| def nfo(msg): | |
| click.echo(click.style("[nfo] {}".format(msg), fg="gray")) | |
| @staticmethod | |
| def dbg(msg): | |
| click.echo(click.style("[dbg] {}".format(msg), fg="blue")) | |
| @staticmethod | |
| def run(msg): | |
| click.echo(click.style("[run] {}".format(msg), fg="green")) | |
| @click.group() | |
| def run(): | |
| pass | |
| @run.command() | |
| def update(): | |
| log.run("Update to latest version.") | |
| remote = "https://gist.githubusercontent.com/omicronns/b7c9b891e4ef4d7c606c128c06678d68/raw/pkgm" | |
| resp = requests.get(remote) | |
| if resp: | |
| newmod = imp.new_module("newmod") | |
| exec(resp.text, newmod.__dict__) | |
| if hasattr(newmod, "PKGM_VERSION"): | |
| log.run("Update from version {} to {}".format(PKGM_VERSION, getattr(newmod, "PKGM_VERSION"))) | |
| with open(sys.argv[0], "w") as script: | |
| script.write(resp.text) | |
| else: | |
| log.err("Unable to download script from remote host {}".format(remote)) | |
| @run.command() | |
| @click.argument("path") | |
| @click.option("--recursive", "r", help="Look for packages inside PATH directory recursively (only one level deep).") | |
| def install(path, r): | |
| pass | |
| if __name__ == "__main__": | |
| run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment