Upload directory recursively via the standard icommands CLI.
    example: irsync -Kvar -R $resource $local_dir i:$irods_dir
    go to https://docs.irods.org/4.2.0/icommands/user/#irsync for more info

def _upload_dir_icommands_cli(local_dir, irods_dir, config=None, metadata=None):
    """
    Upload directory recursively via the standard icommands CLI.
    example: irsync -Kvar -R $resource $local_dir i:$irods_dir
    go to https://docs.irods.org/4.2.0/icommands/user/#irsync for more info
    """

    args = ["-K","-v","-a","-r"]
    if config:
        if config.get("resource"):
            args += ["-R", config.get("resource")]

    _check_create_collection(irods_dir,isdir=True)
    cmd = ["irsync"] + args + [local_dir, "i:"+irods_dir]
    do.run(cmd, "Uploading to iRODS")