Skip to content

Commit

Permalink
Added CLI entrypoint and updated help
Browse files Browse the repository at this point in the history
  • Loading branch information
Jelloeater committed Mar 31, 2023
1 parent 363aae0 commit 409ebf7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ print(device.switch)

### CLI Interface (WIP)
- If you have all the needed env vars loaded you can use the env related options
- If not, just use the cli arg based approach
- If not, just use the cli arg based approach, this should be installed system wide
```bash
python3 -m hubitatcontrol print-devices-env
hubitatcontrol print-devices-env
```

## Docs
Expand Down
16 changes: 15 additions & 1 deletion hubitatcontrol/__main__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
import rich.errors
import typer
from hubitatcontrol import get_hub
from importlib import metadata

app = typer.Typer(no_args_is_help=True)
version = metadata.version("hubitatcontrol")

app = typer.Typer(
no_args_is_help=True,
help='Hubitat Control CLI Interface',
epilog=f'Version: {version} \n Project: https://github.com/Jelloeater/hubitatcontrol',
)


@app.command()
def print_devices_env():
"""
Loads .env file at current location and prints current devices
"""
import os
from dotenv import load_dotenv

Expand All @@ -21,6 +32,9 @@ def print_devices_env():

@app.command()
def print_devices_cli(host_env, token_env, app_id_env: int, cloud_token_env=typer.Argument(None)):
"""
Prints current devices from CLI input
"""
h = get_hub(host=host_env, token=token_env, app_id=app_id_env, cloud_token=cloud_token_env)
print_device_list_types(h)

Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "hubitatcontrol"
version = "1.1.1"
version = "1.1.2"
description = "Hubitat Maker API Interface"
authors = ["Jesse Schoepfer <jelloeater@gmail.com>"]
license = "MIT License"
Expand All @@ -14,6 +14,9 @@ classifiers = ["Development Status :: 5 - Production/Stable",
"Operating System :: OS Independent",
]

[tool.poetry.scripts]
hubitatcontrol = "hubitatcontrol.__main__:app"


[tool.poetry.dependencies]
python = "^3.10"
Expand Down

0 comments on commit 409ebf7

Please sign in to comment.