This repository has been archived by the owner on Dec 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from doctorixx/dev
Add cli usage
- Loading branch information
Showing
4 changed files
with
137 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
numpy~=1.24.4 | ||
numpy-stl~=3.1.1 | ||
requests~=2.32.3 | ||
requests~=2.32.3 | ||
colorama~=0.4.6 | ||
art~=6.2 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,84 @@ | ||
import argparse | ||
from art import tprint | ||
import colorama | ||
from colorama import Back, Fore | ||
|
||
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.username | ||
year = parsed.year | ||
|
||
if filename is None: | ||
filename = f"{username}-{year}.stl" | ||
|
||
process_github_stats(username, year, filename) | ||
|
||
|
||
def ui_mode(): | ||
colorama.init() | ||
|
||
print(Fore.BLUE) | ||
tprint("github-skyline") | ||
print(Fore.RESET) | ||
|
||
print(Fore.BLACK + Back.MAGENTA, end="") | ||
print("Welcome to github-skyline generator By doctorixx", end="") | ||
print(Fore.RESET + Back.RESET, "\n") | ||
|
||
print(Fore.BLACK + Back.WHITE, end="") | ||
print("Enter github username", end="") | ||
print(Fore.RESET + Back.RESET) | ||
username = input("> ") | ||
print() | ||
|
||
print(Fore.BLACK + Back.WHITE, end="") | ||
print("Enter year", end="") | ||
print(Fore.RESET + Back.RESET) | ||
year = input("> ") | ||
print() | ||
|
||
filename = f"{username}-{year}.stl" | ||
print(Fore.YELLOW, end="") | ||
print("[/] Generation started") | ||
print(Fore.RESET, end="") | ||
process_github_stats(username, year, filename) | ||
|
||
print(Fore.GREEN, end="") | ||
print("[+] Generation completed") | ||
print(Fore.RESET, end="") | ||
|
||
print(Fore.GREEN, end="") | ||
print(f"[+] Saved to file ", end="") | ||
print(Fore.LIGHTGREEN_EX + Back.RESET, end="") | ||
print(filename, end="") | ||
print(Fore.RESET + Back.RESET) | ||
|
||
print(Fore.CYAN, end="") | ||
print("Press enter to exit...") | ||
print(Fore.RESET, end="") | ||
|
||
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() |