From aca8b84bae5a41a32b40e49771c9caea6fe62398 Mon Sep 17 00:00:00 2001 From: Eric Matthes Date: Tue, 27 May 2025 08:10:51 -0400 Subject: [PATCH 1/6] Partial implementation of prompt for target dir. --- utils/generator_utils.py | 14 ++++++++++++++ utils/plugin_config.py | 1 + 2 files changed, 15 insertions(+) diff --git a/utils/generator_utils.py b/utils/generator_utils.py index 7bf6f83..c46d78a 100644 --- a/utils/generator_utils.py +++ b/utils/generator_utils.py @@ -29,6 +29,19 @@ def get_plugin_info(plugin_config): msg = "What name do you want to appear in the LICENSE file? " plugin_config.license_name = input(msg) + path_root = Path(__file__).parents[1] + default_target_dir = path_root.parent + msg = "Where do you want to write the new plugin? " + msg += f"\n Default location: {default_target_dir.as_posix()}" + msg += "\n(Press Enter to accept default location, or specify a different location.)" + msg += "\n" + target_dir_response = input(msg) + if not target_dir_response: + plugin_config.target_dir = default_target_dir + else: + plugin_config.target_dir = Path(target_dir_response) + breakpoint() + # Review responses. msg = "\nHere's the information you've provided:" print(msg) @@ -36,6 +49,7 @@ def get_plugin_info(plugin_config): print(f" Package name: {plugin_config.pkg_name}") print(f" Supports --automate-all: {plugin_config.support_automate_all}") print(f" Name on license: {plugin_config.license_name}") + print(f" Path for new plugin: {plugin_config.target_dir}") msg = "\nIs this information correct? (yes/no) " response = input(msg) diff --git a/utils/plugin_config.py b/utils/plugin_config.py index 0871456..baf6b10 100644 --- a/utils/plugin_config.py +++ b/utils/plugin_config.py @@ -10,6 +10,7 @@ class PluginConfig: pkg_name: str = "" support_automate_all: bool = False license_name: str = "" + target_dir: Path = "" def validate(self): """Validate the plugin config.""" From 7811e73ef315bb7a7b07158995dd43d5709abc46 Mon Sep 17 00:00:00 2001 From: Eric Matthes Date: Mon, 8 Sep 2025 08:28:39 -0500 Subject: [PATCH 2/6] Pass args to get_plugin_info(). --- generate_plugin.py | 2 +- utils/generator_utils.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/generate_plugin.py b/generate_plugin.py index ed9f2cd..a66566c 100644 --- a/generate_plugin.py +++ b/generate_plugin.py @@ -24,6 +24,6 @@ def generate_plugin(plugin_config, args): # Parse cli, get required info, and generate plugin. args = cli.parse_cli() plugin_config = PluginConfig() - generator_utils.get_plugin_info(plugin_config) + generator_utils.get_plugin_info(args, plugin_config) generate_plugin(plugin_config, args) \ No newline at end of file diff --git a/utils/generator_utils.py b/utils/generator_utils.py index c46d78a..f837d32 100644 --- a/utils/generator_utils.py +++ b/utils/generator_utils.py @@ -5,7 +5,7 @@ import shutil -def get_plugin_info(plugin_config): +def get_plugin_info(args, plugin_config): """Prompts user for all the info needed to generate a new plugin.""" while True: msg = "What platform are you targeting? (Example: Fly.io) " From 7a3dd35e722ce2a4881b3b9f58fb8866da78905a Mon Sep 17 00:00:00 2001 From: Eric Matthes Date: Mon, 8 Sep 2025 08:31:01 -0500 Subject: [PATCH 3/6] Better comments, return instead of break. --- utils/generator_utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/utils/generator_utils.py b/utils/generator_utils.py index f837d32..148786e 100644 --- a/utils/generator_utils.py +++ b/utils/generator_utils.py @@ -8,9 +8,11 @@ def get_plugin_info(args, plugin_config): """Prompts user for all the info needed to generate a new plugin.""" while True: + # Platform msg = "What platform are you targeting? (Example: Fly.io) " plugin_config.platform_name = input(msg) + # Plugin package name msg = "What's the name of your plugin package? (Example: dsd-flyio) " while True: plugin_config.pkg_name = input(msg) @@ -19,6 +21,7 @@ def get_plugin_info(args, plugin_config): else: print("The package name must start with `dsd-`.") + # --automate-all support msg = "Will your plugin support the --automate-all CLI arg? (yes/no) " response = input(msg) if response.lower() in ("yes", "y"): @@ -26,9 +29,11 @@ def get_plugin_info(args, plugin_config): else: plugin_config.support_automate_all = False + # LICENSE name msg = "What name do you want to appear in the LICENSE file? " plugin_config.license_name = input(msg) + # Path to new plugin path_root = Path(__file__).parents[1] default_target_dir = path_root.parent msg = "Where do you want to write the new plugin? " @@ -54,7 +59,7 @@ def get_plugin_info(args, plugin_config): msg = "\nIs this information correct? (yes/no) " response = input(msg) if response.lower() in ("yes", "y"): - break + return msg = "Sorry, please try again.\n\n" print(msg) From 55accdb1cfbbbeeb3c74e6de2319d3b318a0e917 Mon Sep 17 00:00:00 2001 From: Eric Matthes Date: Mon, 8 Sep 2025 08:32:45 -0500 Subject: [PATCH 4/6] Remove breakpoint. --- utils/generator_utils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/utils/generator_utils.py b/utils/generator_utils.py index 148786e..cd23e0d 100644 --- a/utils/generator_utils.py +++ b/utils/generator_utils.py @@ -45,7 +45,6 @@ def get_plugin_info(args, plugin_config): plugin_config.target_dir = default_target_dir else: plugin_config.target_dir = Path(target_dir_response) - breakpoint() # Review responses. msg = "\nHere's the information you've provided:" From bdb10af0ca5b7a1106a9082ca7c26dac345e6aeb Mon Sep 17 00:00:00 2001 From: Eric Matthes Date: Mon, 8 Sep 2025 08:37:11 -0500 Subject: [PATCH 5/6] Should use args.target_dir in regular workflow. --- utils/generator_utils.py | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/utils/generator_utils.py b/utils/generator_utils.py index cd23e0d..b1dc32c 100644 --- a/utils/generator_utils.py +++ b/utils/generator_utils.py @@ -36,15 +36,27 @@ def get_plugin_info(args, plugin_config): # Path to new plugin path_root = Path(__file__).parents[1] default_target_dir = path_root.parent - msg = "Where do you want to write the new plugin? " - msg += f"\n Default location: {default_target_dir.as_posix()}" - msg += "\n(Press Enter to accept default location, or specify a different location.)" - msg += "\n" - target_dir_response = input(msg) - if not target_dir_response: - plugin_config.target_dir = default_target_dir + + if not args.target_dir: + msg = "Where do you want to write the new plugin? " + msg += f"\n Default location: {default_target_dir.as_posix()}" + msg += "\n(Press Enter to accept default location, or specify a different location.)" + msg += "\n" + target_dir_response = input(msg) + if not target_dir_response: + plugin_config.target_dir = default_target_dir + else: + plugin_config.target_dir = Path(target_dir_response) else: - plugin_config.target_dir = Path(target_dir_response) + # args.target_dir is primarily for testing, but someone may use it directly. + msg = "Is this where you want to write the new plugin? {args.target_dir}" + msg += "\n(Press Enter to use this location, or specify a different location.)" + msg += "\n" + target_dir_response = input(msg) + if not target_dir_response: + plugin_config.target_dir = args.target_dir + else: + plugin_config.target_dir = Path(target_dir_response) # Review responses. msg = "\nHere's the information you've provided:" From 949c40f163fb3dad7a5b91412af61571ceb3d7b6 Mon Sep 17 00:00:00 2001 From: Eric Matthes Date: Mon, 8 Sep 2025 08:39:59 -0500 Subject: [PATCH 6/6] f-string, newline. --- utils/generator_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/generator_utils.py b/utils/generator_utils.py index b1dc32c..5f1c390 100644 --- a/utils/generator_utils.py +++ b/utils/generator_utils.py @@ -49,7 +49,7 @@ def get_plugin_info(args, plugin_config): plugin_config.target_dir = Path(target_dir_response) else: # args.target_dir is primarily for testing, but someone may use it directly. - msg = "Is this where you want to write the new plugin? {args.target_dir}" + msg = f"\nIs this where you want to write the new plugin? {args.target_dir}" msg += "\n(Press Enter to use this location, or specify a different location.)" msg += "\n" target_dir_response = input(msg)