Repository: Avaiga/taipy
File: taipy/common/_cli/_run_cli.py (Python)

Code before:

    @classmethod
    def handle_command(cls):
        args, _ = _TaipyParser._parser.parse_known_args()
        if getattr(args, "which", None) != "run":
            return

        # First 2 args are always (1) Python executable, (2) run
        # Unknown args are passed when running the application but will be ignored
        all_args = sys.argv[2:]

        external_args = []
        try:
            external_args_index = all_args.index("external-args")
        except ValueError:
            pass
        else:
            external_args.extend(all_args[external_args_index + 1 :])
            all_args = all_args[:external_args_index]

        def add_taipy_prefix(key: str):
            """
                Adds the '--taipy-' prefix to command-line arguments starting with '--'.
                If the argument starts with '--no-', inserts 'taipy-' after '--no-'.
                Otherwise, inserts 'taipy-' after '--'.
                """
            if key.startswith("--no-"):
                return key[:5] + "taipy-" + key[5:]
            return key[:2] + "taipy-" + key[2:]

        taipy_args = [add_taipy_prefix(arg) if arg.startswith("--") else arg for arg in all_args]

        try:
            subprocess.run(
                [sys.executable, args.application_main_file, *(external_args + taipy_args)],
                stdout=sys.stdout,
                stderr=sys.stdout,
            )
        except KeyboardInterrupt:
            pass

        sys.exit(0)


Review comment (suggestion):
Fix the indentation

```suggestion
            """Adds the '--taipy-' prefix to command-line arguments starting with '--'.
            If the argument starts with '--no-', inserts 'taipy-' after '--no-'.
            Otherwise, inserts 'taipy-' after '--'.
            """
```

Code after:

    @classmethod
    def handle_command(cls):
        args, _ = _TaipyParser._parser.parse_known_args()
        if getattr(args, "which", None) != "run":
            return

        # First 2 args are always (1) Python executable, (2) run
        # Unknown args are passed when running the application but will be ignored
        all_args = sys.argv[2:]

        external_args = []
        try:
            external_args_index = all_args.index("external-args")
        except ValueError:
            pass
        else:
            external_args.extend(all_args[external_args_index + 1 :])
            all_args = all_args[:external_args_index]

        def add_taipy_prefix(key: str):
            """
            Adds the '--taipy-' prefix to command-line arguments starting with '--'.
            If the argument starts with '--no-', inserts 'taipy-' after '--no-'.
            Otherwise, inserts 'taipy-' after '--'.
            """
            if key.startswith("--no-"):
                return key[:5] + "taipy-" + key[5:]
            return key[:2] + "taipy-" + key[2:]

        taipy_args = [add_taipy_prefix(arg) if arg.startswith("--") else arg for arg in all_args]

        try:
            subprocess.run(
                [sys.executable, args.application_main_file, *(external_args + taipy_args)],
                stdout=sys.stdout,
                stderr=sys.stdout,
            )
        except KeyboardInterrupt:
            pass

        sys.exit(0)