Uninstall a package

    Args:
        package (str): The full path to the package. Can be either a .cab file
            or a folder. Should point to the original source of the package, not
            to where the file is installed. This can also be the name of a package as listed in
            ``dism.installed_packages``
        image (Optional[str]): The path to the root directory of an offline
            Windows image. If `None` is passed, the running operating system is
            targeted. Default is None.
        restart (Optional[bool]): Reboot the machine if required by the install

    Returns:
        dict: A dictionary containing the results of the command

    CLI Example:

    .. code-block:: bash

        # Remove the Calc Package
        salt '*' dism.remove_package Microsoft.Windows.Calc.Demo~6595b6144ccf1df~x86~en~1.0.0.0

        # Remove the package.cab (does not remove C:\\packages\\package.cab)
        salt '*' dism.remove_package C:\\packages\\package.cab

def remove_package(package, image=None, restart=False):
    '''
    Uninstall a package

    Args:
        package (str): The full path to the package. Can be either a .cab file
            or a folder. Should point to the original source of the package, not
            to where the file is installed. This can also be the name of a package as listed in
            ``dism.installed_packages``
        image (Optional[str]): The path to the root directory of an offline
            Windows image. If `None` is passed, the running operating system is
            targeted. Default is None.
        restart (Optional[bool]): Reboot the machine if required by the install

    Returns:
        dict: A dictionary containing the results of the command

    CLI Example:

    .. code-block:: bash

        # Remove the Calc Package
        salt '*' dism.remove_package Microsoft.Windows.Calc.Demo~6595b6144ccf1df~x86~en~1.0.0.0

        # Remove the package.cab (does not remove C:\\packages\\package.cab)
        salt '*' dism.remove_package C:\\packages\\package.cab
    '''
    cmd = ['DISM',
           '/Quiet',
           '/Image:{0}'.format(image) if image else '/Online',
           '/Remove-Package']

    if not restart:
        cmd.append('/NoRestart')

    if '~' in package:
        cmd.append('/PackageName:{0}'.format(package))
    else:
        cmd.append('/PackagePath:{0}'.format(package))

    return __salt__['cmd.run_all'](cmd)