python-kasa/kasa
Steven B 9cffbe9e48
Support child devices in all applicable cli commands (#1020)
Adds a new decorator that adds child options to a command and gets the
child device if the options are set.

- Single definition of options and error handling
- Adds options automatically to command
- Backwards compatible with `--index` and `--name`
- `--child` allows for id and alias for ease of use
- Omitting a value for `--child` gives an interactive prompt

Implements private `_update` to allow the CLI to patch a child `update`
method to call the parent device `update`.

Example help output:
```
$ kasa brightness --help
Usage: kasa brightness [OPTIONS] [BRIGHTNESS]

  Get or set brightness.

Options:
  --transition INTEGER
  --child, --name TEXT            Child ID or alias for controlling sub-
                                  devices. If no value provided will show an
                                  interactive prompt allowing you to select a
                                  child.
  --child-index, --index INTEGER  Child index controlling sub-devices
  --help                          Show this message and exit.
```

Fixes #769
2024-07-02 15:11:19 +02:00
..
interfaces Require explicit feature type (#1006) 2024-06-25 18:30:36 +02:00
iot Support child devices in all applicable cli commands (#1020) 2024-07-02 15:11:19 +02:00
smart Support child devices in all applicable cli commands (#1020) 2024-07-02 15:11:19 +02:00
tests Support child devices in all applicable cli commands (#1020) 2024-07-02 15:11:19 +02:00
__init__.py Make device initialisation easier by reducing required imports (#936) 2024-06-03 19:06:54 +01:00
aestransport.py Fix credential hash to return None on empty credentials (#1029) 2024-07-02 13:43:37 +01:00
cli.py Support child devices in all applicable cli commands (#1020) 2024-07-02 15:11:19 +02:00
credentials.py Cleanup credentials handling (#605) 2024-01-03 19:26:52 +01:00
device_factory.py Move SmartBulb into SmartDevice (#874) 2024-04-29 18:19:44 +01:00
device_type.py Add temperature control module for smart (#848) 2024-04-22 12:39:07 +01:00
device.py Support child devices in all applicable cli commands (#1020) 2024-07-02 15:11:19 +02:00
deviceconfig.py Make device initialisation easier by reducing required imports (#936) 2024-06-03 19:06:54 +01:00
discover.py Drop python3.8 support (#992) 2024-06-19 20:24:12 +02:00
emeterstatus.py Enable and convert to future annotations (#838) 2024-04-17 15:39:24 +02:00
exceptions.py Cache SmartErrorCode creation (#1022) 2024-06-30 10:49:59 +01:00
feature.py Update light transition module to work with child devices (#1017) 2024-06-27 18:52:54 +01:00
httpclient.py Configure mypy to run in virtual environment and fix resulting issues (#989) 2024-06-19 15:07:59 +02:00
iotprotocol.py Enable and convert to future annotations (#838) 2024-04-17 15:39:24 +02:00
json.py Generate AES KeyPair lazily (#687) 2024-01-23 15:29:27 +00:00
klaptransport.py Fix credential hash to return None on empty credentials (#1029) 2024-07-02 13:43:37 +01:00
module.py Fix changing brightness when effect is active (#1019) 2024-07-01 13:59:24 +02:00
modulemapping.py Create common interfaces for remaining device types (#895) 2024-05-10 19:29:28 +01:00
modulemapping.pyi Create common interfaces for remaining device types (#895) 2024-05-10 19:29:28 +01:00
protocol.py Fix credential hash to return None on empty credentials (#1029) 2024-07-02 13:43:37 +01:00
py.typed Add py.typed to flag that the package is typed (#251) 2021-11-15 18:21:24 +01:00
smartprotocol.py Disable multi-request on unknown errors (#1027) 2024-07-01 14:33:28 +01:00
xortransport.py Fix credential hash to return None on empty credentials (#1029) 2024-07-02 13:43:37 +01:00