Explorar o código

refactor: rename _ScaffoldCLI to _CreateCLI and --template option to --application

trgiangdo hai 10 meses
pai
achega
074dcabb70

+ 5 - 5
taipy/_cli/_scaffold_cli.py → taipy/_cli/_create_cli.py

@@ -22,11 +22,11 @@ from ._base_cli._abstract_cli import _AbstractCLI
 from ._base_cli._taipy_parser import _TaipyParser
 from ._base_cli._taipy_parser import _TaipyParser
 
 
 
 
-class _ScaffoldCLI(_AbstractCLI):
+class _CreateCLI(_AbstractCLI):
     _template_map: Dict[str, str] = {}
     _template_map: Dict[str, str] = {}
 
 
     _COMMAND_NAME = "create"
     _COMMAND_NAME = "create"
-    _ARGUMENTS = ["--template"]
+    _ARGUMENTS = ["--application"]
 
 
     @classmethod
     @classmethod
     def generate_template_map(cls, template_path: Optional[pathlib.Path] = None):
     def generate_template_map(cls, template_path: Optional[pathlib.Path] = None):
@@ -49,10 +49,10 @@ class _ScaffoldCLI(_AbstractCLI):
             help="Create a new Taipy application using pre-defined templates.",
             help="Create a new Taipy application using pre-defined templates.",
         )
         )
         create_parser.add_argument(
         create_parser.add_argument(
-            "--template",
+            "--application",
             choices=list(cls._template_map.keys()),
             choices=list(cls._template_map.keys()),
             default="default",
             default="default",
-            help="The Taipy template to create new application.",
+            help="The template name to create a new Taipy application.",
         )
         )
 
 
     @classmethod
     @classmethod
@@ -61,7 +61,7 @@ class _ScaffoldCLI(_AbstractCLI):
         if not args:
         if not args:
             return
             return
         try:
         try:
-            cookiecutter(cls._template_map[args.template])
+            cookiecutter(cls._template_map[args.application])
         except OutputDirExistsException as err:
         except OutputDirExistsException as err:
             error_msg = f"{str(err)}. Please remove the existing directory or provide a new folder name."
             error_msg = f"{str(err)}. Please remove the existing directory or provide a new folder name."
             print(error_msg)  # noqa: T201
             print(error_msg)  # noqa: T201

+ 4 - 4
taipy/_entrypoint.py

@@ -19,9 +19,9 @@ from taipy.core._entity._migrate_cli import _MigrateCLI
 from taipy.core._version._cli._version_cli import _VersionCLI
 from taipy.core._version._cli._version_cli import _VersionCLI
 from taipy.gui._gui_cli import _GuiCLI
 from taipy.gui._gui_cli import _GuiCLI
 
 
+from ._cli._create_cli import _CreateCLI
 from ._cli._help_cli import _HelpCLI
 from ._cli._help_cli import _HelpCLI
 from ._cli._run_cli import _RunCLI
 from ._cli._run_cli import _RunCLI
-from ._cli._scaffold_cli import _ScaffoldCLI
 from .version import _get_version
 from .version import _get_version
 
 
 
 
@@ -46,8 +46,8 @@ def _entrypoint():
     _CoreCLI.create_run_parser()
     _CoreCLI.create_run_parser()
 
 
     _VersionCLI.create_parser()
     _VersionCLI.create_parser()
-    _ScaffoldCLI.generate_template_map()
-    _ScaffoldCLI.create_parser()
+    _CreateCLI.generate_template_map()
+    _CreateCLI.create_parser()
     _MigrateCLI.create_parser()
     _MigrateCLI.create_parser()
     _HelpCLI.create_parser()
     _HelpCLI.create_parser()
 
 
@@ -65,7 +65,7 @@ def _entrypoint():
     _HelpCLI.handle_command()
     _HelpCLI.handle_command()
     _VersionCLI.handle_command()
     _VersionCLI.handle_command()
     _MigrateCLI.handle_command()
     _MigrateCLI.handle_command()
-    _ScaffoldCLI.handle_command()
+    _CreateCLI.handle_command()
 
 
     _TaipyParser._remove_argument("help")
     _TaipyParser._remove_argument("help")
     _TaipyParser._parser.print_help()
     _TaipyParser._parser.print_help()

+ 1 - 1
tests/cli/test_help_cli.py

@@ -58,7 +58,7 @@ def test_help_non_existed_command(caplog):
 
 
 
 
 def test_taipy_create_help(capsys):
 def test_taipy_create_help(capsys):
-    expected_help = "create [-h] [--template"
+    expected_help = "create [-h] [--application"
 
 
     with patch("sys.argv", ["prog", "help", "create"]):
     with patch("sys.argv", ["prog", "help", "create"]):
         with pytest.raises(SystemExit):
         with pytest.raises(SystemExit):

+ 3 - 3
tests/templates/test_template_cli.py

@@ -18,14 +18,14 @@ from taipy._entrypoint import _entrypoint
 
 
 
 
 def test_create_cli_with_wrong_arguments(caplog):
 def test_create_cli_with_wrong_arguments(caplog):
-    with patch("sys.argv", ["prog", "create", "--teamplaet", "default"]):
+    with patch("sys.argv", ["prog", "create", "--applciation", "default"]):
         with pytest.raises(SystemExit):
         with pytest.raises(SystemExit):
             _entrypoint()
             _entrypoint()
-        assert "Unknown arguments: --teamplaet. Did you mean: --template?" in caplog.text
+        assert "Unknown arguments: --applciation. Did you mean: --application?" in caplog.text
 
 
 
 
 def test_create_cli_with_unsupported_template(capsys):
 def test_create_cli_with_unsupported_template(capsys):
-    with patch("sys.argv", ["prog", "create", "--template", "not-a-template"]):
+    with patch("sys.argv", ["prog", "create", "--application", "not-a-template"]):
         with pytest.raises(SystemExit):
         with pytest.raises(SystemExit):
             _entrypoint()
             _entrypoint()
         _, err = capsys.readouterr()
         _, err = capsys.readouterr()