diff --git a/mm.py b/mm.py index 09e15a2..5502b96 100644 --- a/mm.py +++ b/mm.py @@ -13,6 +13,7 @@ import textwrap SCRIPT_VERSION = "0.1" class bcolors: + GREY = '\033[90m' PURPLE = '\033[95m' BLUE = '\033[94m' CYAN = '\033[96m' @@ -26,7 +27,7 @@ class bcolors: # path where the entries are stored DIR_PATH = "/home/vashqlf/Code/Python/mm/pages/" # order of the rows in the table output -KEY_ORDER = ["name", "ipv4", "ipv6", "os", "desc"] +KEY_ORDER = ["name", "desc", "ipv4", "ipv6", "os", "ram", "cores"] # commands that need a name value NAME_CMDS = ["add", "group", "edit", "rm", "view"] @@ -75,11 +76,13 @@ def parse_args() -> dict: parser.add_argument("-n", "--name", required=name_required(), help="name of the page, needs to be unique") - parser.add_argument("--ipv4", required=False) - parser.add_argument("--ipv6", required=False) - parser.add_argument("--os", required=False) - parser.add_argument("--desc", required=False) - parser.add_argument("--group", required=False) + parser.add_argument("-4","--ipv4", required=False) + parser.add_argument("-6","--ipv6", required=False) + parser.add_argument("-o","--os", required=False) + parser.add_argument("-r","--ram", required=False) + parser.add_argument("-c","--cores", required=False) + parser.add_argument("-d","--desc", required=False) + parser.add_argument("-g","--group", required=False) parser.add_argument("--force", required=False, action='store_true') @@ -212,9 +215,9 @@ def print_header(content: str): header = pyfiglet.figlet_format(content, font="cricket", width=TERM_SIZE.columns) print(bcolors.BOLD + bcolors.YELLOW + header + bcolors.ENDC) -def print_page(name: str): +def print_page(name: str, group: str): try: - with open(page_path(name), "r") as fp: + with open(page_path(name, group), "r") as fp: page = json.load(fp) print_header(page["name"]) print_table(page) @@ -234,8 +237,12 @@ def list_pages(): for group in groups: print(f"{bcolors.BOLD}--- {group} ---{bcolors.ENDC}") for dir_item in sorted(os.listdir(DIR_PATH + group)): - print(f"{bcolors.BOLD}{bcolors.BLUE}+ {bcolors.ENDC}{dir_item[:-5]}") - except FileNotFoundError: + with open(page_path(dir_item[:-5], group), "r") as fp: + content = json.load(fp) + desc = content["desc"] if "desc" in content else "" + ram = content["ram"] if "ram" in content else "" + print(f"{bcolors.BOLD}{bcolors.BLUE}+ {bcolors.ENDC}{dir_item[:-5]}\t{bcolors.RED}{desc}\t{bcolors.GREY}{ram}{bcolors.ENDC}") + except FileNotFoundError as e: print_error("Page-Path corrupted, restart mm.") @@ -246,7 +253,7 @@ match args["action"]: case "group": add_group(args["name"]) case "edit": edit_page(args=args) case "rm": delete_item(args["name"]) - case "view": print_page(args["name"]) + case "view": print_page(args["name"], args["group"]) case "ls": list_pages() case "test": print(args) case _: print_welcome() diff --git a/pages/cloud/strato1.json b/pages/cloud/strato1.json index fdac284..462d25d 100644 --- a/pages/cloud/strato1.json +++ b/pages/cloud/strato1.json @@ -1,3 +1,5 @@ { - "name": "strato1" + "name": "strato1", + "desc": "vaultwarden", + "ram": "2GB" } \ No newline at end of file diff --git a/pages/cloud/strato2.json b/pages/cloud/strato2.json index cf954e7..e10fc19 100644 --- a/pages/cloud/strato2.json +++ b/pages/cloud/strato2.json @@ -1,3 +1,5 @@ { - "name": "strato2" + "name": "strato2", + "desc": "blog", + "ram": "2GB" } \ No newline at end of file diff --git a/pages/cloud/strato3.json b/pages/cloud/strato3.json index f61b9c5..4d4ae10 100644 --- a/pages/cloud/strato3.json +++ b/pages/cloud/strato3.json @@ -1,3 +1,5 @@ { - "name": "strato3" + "name": "strato3", + "desc": "checkmk", + "ram": "4GB" } \ No newline at end of file diff --git a/pages/cloud/strato4.json b/pages/cloud/strato4.json index 2530a6b..982a014 100644 --- a/pages/cloud/strato4.json +++ b/pages/cloud/strato4.json @@ -1,3 +1,5 @@ { - "name": "strato4" + "name": "strato4", + "desc": "git", + "ram": "2GB" } \ No newline at end of file diff --git a/pages/cloud/strato5.json b/pages/cloud/strato5.json index 703f408..7707439 100644 --- a/pages/cloud/strato5.json +++ b/pages/cloud/strato5.json @@ -1,3 +1,5 @@ { - "name": "strato5" + "name": "strato5", + "desc": "jumphost", + "ram": "1GB" } \ No newline at end of file diff --git a/pages/cloud/strato6.json b/pages/cloud/strato6.json index a22fe76..d9ae8fa 100644 --- a/pages/cloud/strato6.json +++ b/pages/cloud/strato6.json @@ -1,3 +1,5 @@ { - "name": "strato6" + "name": "strato6", + "desc": "linkding", + "ram": "1GB" } \ No newline at end of file diff --git a/pages/local/fhain1.json b/pages/local/fhain1.json index fbdb0ba..8aad505 100644 --- a/pages/local/fhain1.json +++ b/pages/local/fhain1.json @@ -1,4 +1,5 @@ { "name": "fhain1", - "desc": "automation" + "desc": "automation", + "ram": "12GB" } \ No newline at end of file diff --git a/pages/local/pi1.json b/pages/local/pi1.json index 288cf9d..7ea649a 100644 --- a/pages/local/pi1.json +++ b/pages/local/pi1.json @@ -1,3 +1,5 @@ { - "name": "pi1" + "name": "pi1", + "desc": "manager", + "ram": "2GB" } \ No newline at end of file diff --git a/pages/local/pi2.json b/pages/local/pi2.json index 87b211b..de13521 100644 --- a/pages/local/pi2.json +++ b/pages/local/pi2.json @@ -1,3 +1,5 @@ { - "name": "pi2" + "name": "pi2", + "desc": "misc", + "ram": "1GB" } \ No newline at end of file