import shlex


def build_cmd(infname, outfname, parameters):
    """Build a command-line for swarm"""
    params = [
        "-{0} {1}".format(shlex.quote(str(k)), shlex.quote(str(v)))
        for k, v in parameters._asdict().items()
        if v is not None
    ]
    cmd = ["swarm", *params, "-o", shlex.quote(outfname), shlex.quote(infname)]
    return cmd