Skip to content
This repository has been archived by the owner on Dec 21, 2024. It is now read-only.

Commit

Permalink
Add cli mode
Browse files Browse the repository at this point in the history
  • Loading branch information
doctorixx committed Aug 6, 2024
1 parent f3b431b commit d222e96
Showing 1 changed file with 47 additions and 12 deletions.
59 changes: 47 additions & 12 deletions skyline_wizard.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,50 @@
import argparse

from core import process_github_stats

print("Welcome to github-skyline generator By doctorixx \n")
print("Enter github username")
username = input("> ") # CHANGE TO YOUR USERNAME
print("Enter year")
year = input("> ") # CHANGE TO YOUR YEAR
filename = f"{username}-{year}.stl" # <- Generated filename
print("[/] Generation started")
process_github_stats(username, year, filename)
print("[+] Generation completed")
print(f"[+] Saved to file {filename}")
print("Press enter to exit...")
input()
parser = argparse.ArgumentParser(
prog='skyline_wizard',
description='Utility to generate 3d github skylines models',
epilog='by Doctorixx(https://github.com/doctorixx)')

parser.add_argument('-f', '--filename', dest="filename")
parser.add_argument('-u', '--username', dest="username")
parser.add_argument('-y', '--year', dest="year")


def cli_mode(parsed):
filename = parsed.filename
username = parsed.nickname
year = parsed.year

if filename is None:
filename = f"{username}-{year}.stl"

process_github_stats(username, year, filename)


def ui_mode():
print("Welcome to github-skyline generator By doctorixx \n")
print("Enter github username")
username = input("> ")
print("Enter year")
year = input("> ")
filename = f"{username}-{year}.stl"
print("[/] Generation started")
process_github_stats(username, year, filename)
print("[+] Generation completed")
print(f"[+] Saved to file {filename}")
print("Press enter to exit...")
input()


if __name__ == '__main__':
parsed = parser.parse_args()
used_cli_attrs = any(
map(lambda attr: parsed.__getattribute__(attr), filter(lambda x: not x.startswith("_"), dir(parsed)))
)

if used_cli_attrs:
cli_mode(parsed)
else:
ui_mode()

0 comments on commit d222e96

Please sign in to comment.