def remove(ctx, service_names, is_all):
"""
Remove a service from 21 sell
\b
Removing a service
$ 21 sell remove <service_name>
\b
Removing all services from 21 sell
$ 21 sell remove --all
"""
if not service_names and is_all is False:
raise click.UsageError('No service selected.', ctx=ctx)
manager = ctx.obj['manager']
logger.info(click.style("Removing services.", fg=cli_helpers.TITLE_COLOR))
def service_successfully_removed_hook(tag):
cli_helpers.print_str(tag, ["Removed"], "TRUE", True)
def service_does_not_exists_hook(tag):
cli_helpers.print_str(tag, ["Doesn't exist"], "FALSE", False)
def service_failed_to_remove_hook(tag):
cli_helpers.print_str(tag, ["Failed to remove"], "FALSE", False)
if is_all:
services_to_remove = manager.available_user_services()
else:
services_to_remove = service_names
for service_name in services_to_remove:
manager.remove_service(service_name, service_successfully_removed_hook, service_does_not_exists_hook,
service_failed_to_remove_hook)
评论列表
文章目录