def sos_handle_parameter_(key, defvalue):
    '''Parse command line arguments and set values to parameters section.
    NOTE: parmeters will not be handled if it is already defined in
    the environment. This makes the parameters variable.
    '''
    env.parameter_vars.add(key)
    # if no argument is provided
    if not env.config['workflow_args'] and not env.config['workflow_vars']:
        if isinstance(defvalue, type):
            raise ArgumentError(
                f'Argument {key} of type {defvalue.__name__} is required')
        else:
            return defvalue
    #
    if env.config['workflow_vars']:
        if key in env.config['workflow_vars']:
            return env.config['workflow_vars'][key]

    parser = argparse.ArgumentParser(allow_abbrev=False)
    # thre is a possibility that users specify --cut-off instead of --cut_off for parameter
    # cut_off. It owuld be nice to allow both.
    #
    # Argparse would produce cut_off for both definition of --cut-off and --cut_off, however
    # you can only use the matching input...
    from .targets import path, paths, sos_targets, file_target
    ret_type = None

    if isinstance(defvalue, type) or defvalue is None:
        if defvalue == bool:
            feature_parser = parser.add_mutually_exclusive_group(required=True)
            feature_parser.add_argument(
                f'--{key}', dest=key, action='store_true')
            feature_parser.add_argument(
                f'--no-{key}', dest=key, action='store_false')
            if '_' in key:
                feature_parser.add_argument(
                    f'--{key.replace("_", "-")}', dest=key, action='store_true')
                feature_parser.add_argument(
                    f'--no-{key.replace("_", "-")}',
                    dest=key,
                    action='store_false')
        else:
            if defvalue is None:
                defvalue = str
            if defvalue in (sos_targets, paths):
                ret_type = defvalue
            # if only a type is specified, it is a required document of required type
            if '_' in key:
                feature_parser = parser.add_mutually_exclusive_group(
                    required=True)
                feature_parser.add_argument(
                    f'--{key}',
                    dest=key,
                    type=str if hasattr(defvalue, '__iter__') and
                    defvalue not in (file_target, path) else defvalue,
                    help='',
                    nargs='+' if defvalue not in (str, file_target) and
                    hasattr(defvalue, '__iter__') else '?')
                feature_parser.add_argument(
                    f'--{key.replace("_", "-")}',
                    dest=key,
                    type=str if hasattr(defvalue, '__iter__') and
                    defvalue not in (file_target, path) else defvalue,
                    help='',
                    nargs='+' if defvalue not in (str, file_target) and
                    hasattr(defvalue, '__iter__') else '?')
            else:
                parser.add_argument(
                    f'--{key}',
                    dest=key,
                    type=str if hasattr(defvalue, '__iter__') and
                    defvalue not in (file_target, path) else defvalue,
                    help='',
                    required=True,
                    nargs='+' if defvalue not in (str, file_target, path) and
                    hasattr(defvalue, '__iter__') else '?')
    else:
        if isinstance(defvalue, bool):
            feature_parser = parser.add_mutually_exclusive_group(required=False)
            feature_parser.add_argument(
                f'--{key}', dest=key, action='store_true')
            feature_parser.add_argument(
                f'--no-{key}', dest=key, action='store_false')
            if '_' in key:
                feature_parser.add_argument(
                    f'--{key.replace("_", "-")}', dest=key, action='store_true')
                feature_parser.add_argument(
                    f'--no-{key.replace("_", "-")}',
                    dest=key,
                    action='store_false')
            feature_parser.set_defaults(**{key: defvalue})
        else:
            if isinstance(defvalue, (file_target, path)):
                deftype = type(defvalue)
            elif isinstance(defvalue, paths):
                deftype = path
                ret_type = type(defvalue)
            elif isinstance(defvalue, sos_targets):
                deftype = file_target
                ret_type = type(defvalue)
            elif isinstance(defvalue, str):
                deftype = str
            elif isinstance(defvalue, Sequence):
                if len(defvalue) > 0:
                    deftype = type(defvalue[0])
                else:
                    deftype = str
            else:
                deftype = type(defvalue)

            if '_' in key:
                feature_parser = parser.add_mutually_exclusive_group(
                    required=False)
                feature_parser.add_argument(
                    f'--{key}',
                    dest=key,
                    type=deftype,
                    nargs='*' if isinstance(defvalue, Sequence) and
                    not isinstance(defvalue, str) else '?',
                    default=defvalue)
                feature_parser.add_argument(
                    f'--{key.replace("_", "-")}',
                    dest=key,
                    type=deftype,
                    nargs='*' if isinstance(defvalue, Sequence) and
                    not isinstance(defvalue, str) else '?',
                    default=defvalue)
            else:
                parser.add_argument(
                    f'--{key}',
                    dest=key,
                    type=deftype,
                    nargs='*' if isinstance(defvalue, Sequence) and
                    not isinstance(defvalue, str) else '?',
                    default=defvalue)
    #
    parser.error = _parse_error
    parsed, _ = parser.parse_known_args(env.config['workflow_args'])
    return ret_type(vars(parsed)[key]) if ret_type else vars(parsed)[key]
Parse command line arguments and set values to parameters section.
    NOTE: parmeters will not be handled if it is already defined in
    the environment. This makes the parameters variable.