Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 3 additions & 22 deletions kasa/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@
help="The broadcast address to be used for discovery.",
)
@click.option("-d", "--debug", envvar="KASA_DEBUG", default=False, is_flag=True)
@click.option("--bulb", default=False, is_flag=True)
@click.option("--plug", default=False, is_flag=True)
@click.option("--lightstrip", default=False, is_flag=True)
@click.option("--strip", default=False, is_flag=True)
@click.option(
"--type",
envvar="KASA_TYPE",
Expand All @@ -65,7 +61,7 @@
)
@click.version_option(package_name="python-kasa")
@click.pass_context
async def cli(ctx, host, alias, target, debug, bulb, plug, lightstrip, strip, type):
async def cli(ctx, host, alias, target, debug, type):
"""A tool for controlling TP-Link smart home devices.""" # noqa
# no need to perform any checks if we are just displaying the help
if sys.argv[-1] == "--help":
Expand Down Expand Up @@ -95,19 +91,6 @@ async def cli(ctx, host, alias, target, debug, bulb, plug, lightstrip, strip, ty
await ctx.invoke(discover)
return

if bulb or plug or strip or lightstrip:
click.echo(
"Using --bulb, --plug, --strip, and --lightstrip is deprecated. Use --type instead to define the type"
)
if bulb:
type = "bulb"
elif plug:
type = "plug"
elif strip:
type = "strip"
elif lightstrip:
type = "lightstrip"

if type is not None:
dev = TYPE_TO_CLASS[type](host)
else:
Expand Down Expand Up @@ -158,9 +141,8 @@ async def join(dev: SmartDevice, ssid, password, keytype):

@cli.command()
@click.option("--timeout", default=3, required=False)
@click.option("--dump-raw", is_flag=True)
@click.pass_context
async def discover(ctx, timeout, dump_raw):
async def discover(ctx, timeout):
"""Discover devices in the network."""
target = ctx.parent.params["target"]
click.echo(f"Discovering devices on {target} for {timeout} seconds")
Expand Down Expand Up @@ -201,8 +183,7 @@ async def sysinfo(dev):

@cli.command()
@pass_dev
@click.pass_context
async def state(ctx, dev: SmartDevice):
async def state(dev: SmartDevice):
"""Print out device state and versions."""
click.echo(click.style(f"== {dev.alias} - {dev.model} ==", bold=True))
click.echo(f"\tHost: {dev.host}")
Expand Down
16 changes: 0 additions & 16 deletions kasa/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,22 +106,6 @@ async def test_brightness(dev):
assert "Brightness: 12" in res.output


def _generate_type_class_pairs():
yield from TYPE_TO_CLASS.items()


@pytest.mark.parametrize("type_class", _generate_type_class_pairs())
async def test_deprecated_type(dev, type_class, mocker):
"""Make sure that using deprecated types yields a warning."""
type, cls = type_class
if type == "dimmer":
return
runner = CliRunner()
with mocker.patch("kasa.SmartDevice.update"):
res = await runner.invoke(cli, ["--host", "127.0.0.2", f"--{type}"])
assert "Using --bulb, --plug, --strip, and --lightstrip is deprecated" in res.output


async def test_temperature(dev):
pass

Expand Down