def set_subcommands(func, parser):
    """
    Set subcommands.
    """
    if hasattr(func, '__subcommands__') and func.__subcommands__:
        sub_parser = parser.add_subparsers(
            title=SUBCOMMANDS_LIST_TITLE, dest='subcommand',
            description=SUBCOMMANDS_LIST_DESCRIPTION.format(
                func.__cmd_name__),
            help=func.__doc__)
        for sub_func in func.__subcommands__.values():
            parser = get_parser(sub_func, sub_parser)
            for args, kwargs in get_shared(sub_func):
                parser.add_argument(*args, **kwargs)
    else:
        for args, kwargs in get_shared(func):
            parser.add_argument(*args, **kwargs)
Set subcommands.