@staticmethod
def _parse_flag(key, value, param):
    """Parses both standard --flag and --on/--off switch style of flags
        This is complicated by the fact that the following values are accepted in the command file:
        - flag: False
        - flag: True
        - on: True
        - on: False
        - off: True
        - off: False
        This creates semantic difficulties.

        For a standard flag, the behavior depends on the default value. In click a flag with a
        default value of True becomes False when the flag is used, and a flag with a default value
        of False becomes True when the flag is used. In the command file, a value of True is
        interpreted to mean that the user wants to pass the flag into the command, which leads to
        the following truth table:

        Default | Value | Result
        -------------------------
        True    | True  | False
        True    | False | True
        False   | True  | True
        False   | False | False

        For switch-style flags, the behavior does not depend on the default value of the flag.
        Instead, using the --on/--off example, --on always results in True, and --off always
        results in False. Therefore, an "on: False" value in the command file is equivalent to
        "off: True", and an "off: False" value in the command file is equivalent to "on: True".
        The secondary name in this example is --off.
        This yields the following truth table (using the --on/--off example):

        Name | Secondary | Value | Result
        ---------------------------------
        on   | False     | True  | True
        on   | False     | False | False
        off  | True      | True  | False
        off  | True      | False | True
        """
    is_switch_flag = bool(param.secondary_opts)
    if not is_switch_flag:
        return value != param.default
    else:
        is_using_secondary = ('--' + key in param.secondary_opts or '-' +
            key in param.secondary_opts)
        return value != is_using_secondary
