def get_cmd_names(cmd_name, ctx):
    """
    Given the click core context, return a list representing all the subcommands passed to the CLI

    Parameters
    ----------
    cmd_name : name of current command

    ctx : click.Context

    Returns
    -------
    list(str)
        List containing subcommand names. Ex: ["local", "start-api"]

    """
    if not ctx:
        return []
    if ctx and not getattr(ctx, 'parent', None):
        return [ctx.info_name]
    _parent = ctx.parent
    _cmd_names = []
    if cmd_name != ctx.info_name:
        _cmd_names = [cmd_name]
    _cmd_names.append(ctx.info_name)
    while _parent.parent:
        info_name = _parent.info_name
        _cmd_names.append(info_name)
        _parent = _parent.parent
    _cmd_names.reverse()
    return _cmd_names
