Update command args and readme

This commit is contained in:
IamTheFij 2024-07-08 10:38:37 -07:00
parent e45dc59d1f
commit d950f0c521
2 changed files with 36 additions and 9 deletions

View File

@ -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 <package_url> --name <package_name> --version <version>
unhacs add <package_url> --version <version>
```
If the package already exists, you can update it by adding the `--update` flag:
```bash
unhacs add --url <package_url> --update
unhacs add <package_url> --update
```
If the package is a Lovelace plugin, you must specify it using the `--plugin` flag:
```bash
unhacs add --plugin <package_url>
```
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 <file_path>
```
### List packages

View File

@ -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."
)