Support multiple paths for get-value
This commit is contained in:
@@ -49,19 +49,20 @@ async def cli(ctx: click.Context, host: str, username: str, password: str, authe
|
|||||||
|
|
||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
@click.option('--path', required=True)
|
@click.option('--path', required=True, multiple=True)
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
async def get_value(ctx: click.Context, path: str) -> None:
|
async def get_value(ctx: click.Context, path: str) -> None:
|
||||||
client = ctx.find_object(SagemcomClient)
|
client = ctx.find_object(SagemcomClient)
|
||||||
if client is None:
|
if client is None:
|
||||||
return
|
return
|
||||||
try:
|
for _path in path:
|
||||||
value = await client.get_value_by_xpath(path)
|
try:
|
||||||
except Exception as e:
|
value = await client.get_value_by_xpath(_path)
|
||||||
click.echo(e, err=True)
|
except Exception as e:
|
||||||
raise click.Abort()
|
click.echo(e, err=True)
|
||||||
else:
|
raise click.Abort()
|
||||||
click.echo(json.dumps(value, indent=2))
|
else:
|
||||||
|
click.echo(json.dumps(value, indent=2))
|
||||||
|
|
||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
|
|||||||
Reference in New Issue
Block a user