summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSanto Cariotti <dcariotti24@gmail.com>2020-03-27 20:39:40 +0100
committerSanto Cariotti <dcariotti24@gmail.com>2020-03-27 21:08:24 +0100
commitc57b5e7d993a58383d471e0080e4a51275cfdcb4 (patch)
treeee40dee151e1cc29fc94c69582437f91e8393ac4
parentaf205a074dc1c52b45c463ac9671fd729d8055c1 (diff)
feat: colored logging
-rw-r--r--src/frest/manage.py15
-rw-r--r--src/frest/manage/utils.py34
2 files changed, 46 insertions, 3 deletions
diff --git a/src/frest/manage.py b/src/frest/manage.py
index 3cb0d2c..4656f1a 100644
--- a/src/frest/manage.py
+++ b/src/frest/manage.py
@@ -1,11 +1,24 @@
import argparse
-from manage.utils import *
+from manage.utils import logo, create_app
+from manage.utils import logging
+import os
def main():
parser = argparse.ArgumentParser()
+ parser.add_argument("--startapp", "-s", type=str, help="create new app")
args = parser.parse_args()
+ if args.startapp:
+ if not os.path.exists("scheme"):
+ logging("Create ")
+ logging("scheme/", 0)
+ logging("... ")
+ logging("OK", 3, "\n")
+ os.makedirs("scheme")
+
+ create_app(args.startapp.lower())
+
if __name__ == "__main__":
logo()
diff --git a/src/frest/manage/utils.py b/src/frest/manage/utils.py
index be41419..30e3801 100644
--- a/src/frest/manage/utils.py
+++ b/src/frest/manage/utils.py
@@ -1,9 +1,39 @@
+class bcolors(object):
+ DARK_GREY = "\033[90m"
+ BOLD = "\033[1m"
+ ERROR = "\033[91m"
+ OK = "\033[92m"
+ WARNING = "\033[93m"
+ ENDC = "\033[0m"
+
+
+COLORS = [
+ bcolors.DARK_GREY,
+ bcolors.BOLD,
+ bcolors.ERROR,
+ bcolors.OK,
+ bcolors.WARNING,
+ bcolors.ENDC,
+]
+ENDC = len(COLORS) - 1
+
+
+def logging(text, _type=ENDC, end=""):
+ print(f"{COLORS[_type]}{text}{COLORS[ENDC]}", end=end)
+
+
def logo():
- print('''
+ print(
+ """
__ _
/ _| | |
| |_ _ __ ___ ___| |_
| _| '__/ _ \/ __| __|
| | | | | __/\__ \ |_
|_| |_| \___||___/\__|
- \n\n''')
+ \n\n"""
+ )
+
+
+def create_app(name):
+ pass