Skip to content

Commit

Permalink
fix(devices): improves code quality
Browse files Browse the repository at this point in the history
  • Loading branch information
RomilShah committed Aug 22, 2023
1 parent 57353f5 commit 9e490f3
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions riocli/device/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@
@click.option('--force', '-f', '--silent', is_flag=True, default=False,
help='Skip confirmation')
@click.option('--delete-all', '-a', is_flag=True, default=False,
help='deletes all devices')
help='Delete all devices')
@click.option('--workers', '-w',
help="number of parallel workers while running delete devices "
"command. defaults to 10.", type=int, default=10)
help="Number of parallel workers for deleting devices. Defaults to 10.", type=int, default=10)
@click.argument('device-name-or-regex', type=str, default="")
@with_spinner(text='Deleting device...')
def delete_device(
Expand Down Expand Up @@ -123,13 +122,20 @@ def delete_device(
tabulate_data(data, headers=['Name', 'Status'])

spinner.write('')
if success_count:

if failed_count == 0:
spinner.text = click.style(
'{0} Devices(s) deleted successfully.'.format(success_count), Colors.GREEN)
'All Devices(s) deleted successfully.', Colors.GREEN)
spinner.ok(click.style(Symbols.SUCCESS, Colors.GREEN))
if failed_count:

elif success_count == 0:
spinner.text = click.style(
'Failed to delete devices', Colors.YELLOW)
spinner.ok(click.style(Symbols.WARNING, Colors.YELLOW))

else:
spinner.text = click.style(
'{0} Devices(s) deletion failed.'.format(failed_count), Colors.YELLOW)
'{}/{} devices deleted successfully'.format(success_count, success_count+failed_count), Colors.YELLOW)
spinner.ok(click.style(Symbols.WARNING, Colors.YELLOW))
except Exception as e:
spinner.text = click.style(
Expand Down

0 comments on commit 9e490f3

Please sign in to comment.