INNER CODE UNIT · Python

flag_args

renezander030/capcut-cli · python/capcut/__init__.py:124

def flag_args(flags: Mapping[str, Any]) -> List[str]:
    """``{"font_size": 16, "karaoke": True, "tag": ["a", "b"]}`` → ``["--font-size", "16", "--karaoke", "--tag", "a", "--tag", "b"]``."""
    out: List[str] = []
    for key, value in flags.items():
        flag = "--" + key.replace("_", "-")
        if value is None or value is False:
            continue
        if value is True:
            out.append(flag)
        elif isinstance(value, (list, tuple)):
            for item in value:
                out.extend([flag, str(item)])
        else:
            out.extend([flag, str(value)])
    return out


def _spawn(argv: List[str], *, input: Optional[str], timeout: Optional[float], cwd: Optional[str]) -> "subprocess.CompletedProcess[str]":

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…