From 7892e09047df44b6b4b2434ae29cb53615303658 Mon Sep 17 00:00:00 2001 From: Kanishk Pachauri Date: Mon, 17 Jul 2023 03:47:53 +0530 Subject: [PATCH 1/2] feat: Added --version cli argument flag to check the current version of Robyn --- robyn/__main__.py | 9 ++++++++- robyn/argument_parser.py | 7 +++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/robyn/__main__.py b/robyn/__main__.py index 37fc27f4f..e10b7f161 100644 --- a/robyn/__main__.py +++ b/robyn/__main__.py @@ -1,7 +1,7 @@ import os import webbrowser - from .argument_parser import Config +from robyn import __version__ def check(value, input_name): @@ -77,6 +77,10 @@ def docs(): webbrowser.open("https://sansyrox.github.io/robyn/#/") +def version(): + print(f"Robyn {__version__}") + + if __name__ == "__main__": config = Config() if config.create: @@ -84,3 +88,6 @@ def docs(): if config.docs: docs() + + if config.version: + version() diff --git a/robyn/argument_parser.py b/robyn/argument_parser.py index 3257de7b5..aa7246b7c 100644 --- a/robyn/argument_parser.py +++ b/robyn/argument_parser.py @@ -51,6 +51,12 @@ def __init__(self) -> None: default=False, help="Open the browser on successful start.", ) + parser.add_argument( + "--version", + action="store_true", + default=False, + help="Know the current installed version of Robyn", + ) args, _ = parser.parse_known_args() @@ -60,6 +66,7 @@ def __init__(self) -> None: self.create = args.create self.docs = args.docs self.open_browser = args.open_browser + self.version = args.version if self.dev and (self.processes != 1 or self.workers != 1): raise Exception("--processes and --workers shouldn't be used with --dev") From 94b8b3202d7524c7164fa4dbb9fec874a560a71e Mon Sep 17 00:00:00 2001 From: Kanishk Pachauri Date: Mon, 17 Jul 2023 04:38:31 +0530 Subject: [PATCH 2/2] docs: Added docs for the --verison flag of robyn cli feat: Improved the current --create flag of robyn cli with new style Update the requirement.txt for new deps in cli fix: Removed some mistaken additon of --version flag in docs [fix]: Updated the link of robyn docs fixed the doc's link Removed --version docs. removed --version flag from CLI removed --version flag from CLI --- pyproject.toml | 1 + robyn/__main__.py | 38 ++++++++++++++++++-------------------- robyn/argument_parser.py | 7 ------- 3 files changed, 19 insertions(+), 27 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c9ae63e66..68c48950e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,6 +57,7 @@ Changelog = "https://github.com/sparckles/robyn/blob/main/CHANGELOG.md" [tool.poetry.dependencies] python = "^3.7" +inquirerpy = "0.3.4" maturin = "0.14.12" watchdog = "2.2.1" multiprocess = "0.70.14" diff --git a/robyn/__main__.py b/robyn/__main__.py index e10b7f161..c84d55a28 100644 --- a/robyn/__main__.py +++ b/robyn/__main__.py @@ -1,22 +1,26 @@ import os import webbrowser +from InquirerPy import prompt +from InquirerPy.base.control import Choice from .argument_parser import Config -from robyn import __version__ - - -def check(value, input_name): - while value not in ["Y", "N"]: - print("Invalid input. Please enter Y or N") - value = input(f"Need {input_name}? (Y/N) ") - return value def create_robyn_app(): - project_dir = input("Enter the name of the project directory: ") - docker = input("Need Docker? (Y/N) ") - - # Initailize a new Robyn project - docker = check(docker, "Docker") + questions = [ + {"type": "input", "message": "Enter the name of the project directory:"}, + { + "type": "list", + "message": "Need Docker? (Y/N)", + "choices": [ + Choice("Y", name="Y"), + Choice("N", name="N"), + ], + "default": None, + }, + ] + result = prompt(questions=questions) + project_dir = result[0] + docker = result[1] print(f"Creating a new Robyn project '{project_dir}'...") @@ -74,12 +78,9 @@ def index(): def docs(): print("Opening Robyn documentation... | Offline docs coming soon!") - webbrowser.open("https://sansyrox.github.io/robyn/#/") + webbrowser.open("https://sparckles.github.io/robyn/#/") -def version(): - print(f"Robyn {__version__}") - if __name__ == "__main__": config = Config() @@ -88,6 +89,3 @@ def version(): if config.docs: docs() - - if config.version: - version() diff --git a/robyn/argument_parser.py b/robyn/argument_parser.py index aa7246b7c..3257de7b5 100644 --- a/robyn/argument_parser.py +++ b/robyn/argument_parser.py @@ -51,12 +51,6 @@ def __init__(self) -> None: default=False, help="Open the browser on successful start.", ) - parser.add_argument( - "--version", - action="store_true", - default=False, - help="Know the current installed version of Robyn", - ) args, _ = parser.parse_known_args() @@ -66,7 +60,6 @@ def __init__(self) -> None: self.create = args.create self.docs = args.docs self.open_browser = args.open_browser - self.version = args.version if self.dev and (self.processes != 1 or self.workers != 1): raise Exception("--processes and --workers shouldn't be used with --dev")