import typing
import shlex


def command_args(
    arguments: typing.Optional[typing.Union[str, typing.List[str]]]
) -> typing.List[str]:
    """Parse command arguments as string or list."""
    if arguments:
        if isinstance(arguments, str):
            return shlex.split(arguments)

        return arguments

    return []