Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend cli to allow defining --child across all relevant commands #769

Closed
rytilahti opened this issue Feb 19, 2024 · 2 comments · Fixed by #1020
Closed

Extend cli to allow defining --child across all relevant commands #769

rytilahti opened this issue Feb 19, 2024 · 2 comments · Fixed by #1020

Comments

@rytilahti
Copy link
Member

At the moment, only feature and command commands accept --child.
Other relevant commands (on/off, brightness, color temperature, ..) should also accept defining which device is being controlled,
perhaps the best way would be to move the option to be available for all commands?

@rytilahti
Copy link
Member Author

This is not really that necessary for the .0 release (if at all?), so I removed the milestone but keep this open just in case we want to revisit it.

@sdb9696
Copy link
Collaborator

sdb9696 commented May 8, 2024

Also removed from the 0.7 META series

@rytilahti rytilahti linked a pull request Jul 2, 2024 that will close this issue
rytilahti pushed a commit that referenced this issue Jul 2, 2024
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants