def flag(string):
    """
    Conversion function for commandline flags.
       
    Converts string literals given at the commandline as values for
    commandline flags (basically :code:`bool` valued options) to
    :obj:`bool`.

    Literals interpreted as :code:`True`: :code:`yes`, :code:`y`,
    :code:`True`, :code:`true`, :code:`on`, :code:`0`, :code:`active`.

    Literals interpreted as :code:`False`: :code:`no`, :code:`n`,
    :code:`False`, :code:`false`, :code:`off`, :code:`1`,
    :code:`inactive`.
    """
    if string in ['yes', 'y', 'True', 'true', 'on', '0', 'active']:
        return True
    elif string in ['no', 'n', 'False', 'false', 'off', '1', 'inactive']:
        return False
    raise ValueError('cannot convert ' + repr(string) + ' as flag')
