sell.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:two1-python 作者: 21dotco 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号