commandsession/commandsession.py
def unpack_pargs(positional_args, param_kwargs, gnu=False):
        """Unpack multidict and positional args into a
        list appropriate for subprocess.
        :param param_kwargs: 
            ``ParamDict`` storing '--param' style data.
        :param positional_args: flags
        :param gnu: 
            if True, long-name args are unpacked as:
                --parameter=argument
            otherwise, they are unpacked as:
                --parameter argument
        :returns: list appropriate for sending to subprocess
        """

        def _transform(argname):
            """Transform a python identifier into a 
            shell-appropriate argument name
            """
            if len(argname) == 1:
                return '-{}'.format(argname)

            return '--{}'.format(argname.replace('_', '-'))

        args = []
        for item in param_kwargs.keys():
            for value in param_kwargs.getlist(item):
                if gnu:
                    args.append('{}={}'.format(
                        _transform(item),
                        value
                    ))
                else:
                    args.extend([
                        _transform(item),
                        value
                    ])
        if positional_args: 
            for item in positional_args:    
                args.append(_transform(item))

        return args
def unpack_pargs(positional_args, param_kwargs, gnu=False):
        """Unpack multidict and positional args into a
        list appropriate for subprocess.
        :param param_kwargs: 
            ``ParamDict`` storing '--param' style data.
        :param positional_args: flags
        :param gnu: 
            if True, long-name args are unpacked as:
                --parameter=argument
            otherwise, they are unpacked as:
                --parameter argument
        :returns: list appropriate for sending to subprocess
        """

        def _transform(argname):
            """Transform a python identifier into a 
            shell-appropriate argument name
            """
            if len(argname) == 1:
                return '-{}'.format(argname)

            return '--{}'.format(argname.replace('_', '-'))

        args = []
        for item in param_kwargs.keys():
            for value in param_kwargs.getlist(item):
                if gnu:
                    args.append('{}={}'.format(
                        _transform(item),
                        value
                    ))
                else:
                    args.extend([
                        _transform(item),
                        value
                    ])
        if positional_args: 
            for item in positional_args:    
                args.append(_transform(item))

        return args
Unpack multidict and positional args into a
        list appropriate for subprocess.
        :param param_kwargs: 
            ``ParamDict`` storing '--param' style data.
        :param positional_args: flags
        :param gnu: 
            if True, long-name args are unpacked as:
                --parameter=argument
            otherwise, they are unpacked as:
                --parameter argument
        :returns: list appropriate for sending to subprocess