diff --git a/README.md b/README.md index a2ab2aa..e0312bd 100644 --- a/README.md +++ b/README.md @@ -17,13 +17,25 @@ Unhacs provides several commands to manage your Home Assistant packages: To add a package, use the `add` command followed by the URL of the package. Optionally, you can specify the package name and version: ```bash -unhacs add --url --name --version +unhacs add --version ``` If the package already exists, you can update it by adding the `--update` flag: ```bash -unhacs add --url --update +unhacs add --update +``` + +If the package is a Lovelace plugin, you must specify it using the `--plugin` flag: + +```bash +unhacs add --plugin +``` + +If you already have a list of packages in a file, you can add them all at once using the `--file` flag: + +```bash +unhacs add --file ``` ### List packages diff --git a/unhacs/main.py b/unhacs/main.py index 6713508..60ad3ad 100644 --- a/unhacs/main.py +++ b/unhacs/main.py @@ -32,20 +32,33 @@ def create_parser(): subparsers = parser.add_subparsers(dest="subcommand", required=True) + # List installed packages list_parser = subparsers.add_parser("list", description="List installed packages.") list_parser.add_argument("--verbose", "-v", action="store_true") + # Add packages add_parser = subparsers.add_parser("add", description="Add or install packages.") - add_parser.add_argument( + + package_group = add_parser.add_mutually_exclusive_group(required=True) + package_group.add_argument( "--file", "-f", type=Path, help="The path to a package file." ) - add_parser.add_argument( - "--type", - "-t", - type=PackageType, - help="The type of the package. Defaults to 'integration'.", + package_group.add_argument( + "url", nargs="?", type=str, help="The URL of the package." ) - add_parser.add_argument("url", nargs="?", type=str, help="The URL of the package.") + + package_type_group = add_parser.add_mutually_exclusive_group() + package_type_group.add_argument( + "--integration", + action="store_const", + dest="type", + const=PackageType.INTEGRATION, + default=PackageType.INTEGRATION, + ) + package_type_group.add_argument( + "--plugin", action="store_const", dest="type", const=PackageType.PLUGIN + ) + add_parser.add_argument( "--version", "-v", type=str, help="The version of the package." ) @@ -56,11 +69,13 @@ def create_parser(): help="Update the package if it already exists.", ) + # Remove packages remove_parser = subparsers.add_parser( "remove", description="Remove installed packages." ) remove_parser.add_argument("packages", nargs="+") + # Upgrade packages update_parser = subparsers.add_parser( "upgrade", description="Upgrade installed packages." )