Skip to content

Commit

Permalink
Minor fixes for CLI
Browse files Browse the repository at this point in the history
Signed-off-by: Travis F. Collins <[email protected]>
  • Loading branch information
tfcollins committed Sep 23, 2024
1 parent eced4da commit 1be4ac1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 35 deletions.
27 changes: 13 additions & 14 deletions bench/cli/iiotools.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import click

import iio
try:
import iio
except ImportError:
click.echo("IIO not found, please install pylibiio")
exit(1)


@click.group()
@click.option("--uri", "-u", help="URI of target device/board")
Expand All @@ -16,15 +21,12 @@ def cli(ctx, uri, device, complex):


@cli.command()
@click.option("--attribute", "-a", help="Attribute to access", required=True)
@click.pass_context
def get(ctx, attribute):
"""Get an attribute from a device"""
click.echo(f"Get {attribute} from {ctx.obj['uri']}")

@cli.command()
@click.option("--frequency", "-f", help="Set the frequency of the DDS in Hz", required=True)
@click.option("--amplitude", "-a", help="Set the amplitude of the DDS in 0->1", required=True)
@click.option(
"--frequency", "-f", help="Set the frequency of the DDS in Hz", required=True
)
@click.option(
"--amplitude", "-a", help="Set the amplitude of the DDS in 0->1", required=True
)
@click.option("--channel", "-c", help="Set the channel of the DDS", required=True)
@click.pass_context
def set_dds(ctx, frequency, amplitude, channel):
Expand Down Expand Up @@ -52,7 +54,7 @@ def set_dds(ctx, frequency, amplitude, channel):
ch = int(channel) * 4
channels = [ch, ch + 1]
else:
ch = int(channel)*2
ch = int(channel) * 2
channels = [ch, ch + 1]

for i, ch in enumerate(channels):
Expand All @@ -70,6 +72,3 @@ def set_dds(ctx, frequency, amplitude, channel):
chan.attrs["phase"].value = "0"

click.echo(f"Set DDS of channel {channel} to {frequency}Hz and {amplitude} scale")



19 changes: 0 additions & 19 deletions bench/cli/main.py

This file was deleted.

1 change: 1 addition & 0 deletions bench/cli/visatools.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def cli(ctx, uri):
ctx.obj = {}
ctx.obj["uri"] = uri


@cli.command()
@click.pass_context
def list(ctx, attribute):
Expand Down
4 changes: 2 additions & 2 deletions doc/source/cli.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Command Line Interface Tools

The following command line tools are available in the when the optional `cli` dependency is installed.
The following command line tools are available in the when the optional `cli` dependency is installed.

```bash
pip install pybench[cli]
Expand Down Expand Up @@ -29,4 +29,4 @@ There are two command line tools available:
:nested: full
```
```

0 comments on commit 1be4ac1

Please sign in to comment.