fab-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Fab-user] put() and command line args


From: Jeff Forcier
Subject: Re: [Fab-user] put() and command line args
Date: Mon, 20 Oct 2008 16:51:59 -0400

> It's kwargs.keys() instead of values(), but otherwise this is the only
> way to do it.
>
> However!!! I just fixed it so it works with values() and your
> multiple-arguments trick above.
>
> Maybe it's something you had in your own branch?

Hrm...well, I don't recall changing _parse_args much, this is what it
looks like in my execution branch right now:

def _parse_args(args):
    cmds = []
    for cmd in args:
        cmd_args = {}
        if ':' in cmd:
            cmd, cmd_str_args = cmd.split(':', 1)
            for cmd_arg_kv in cmd_str_args.split(','):
                k, _, v = partition(cmd_arg_kv, '=')
                cmd_args[k] = (v % ENV)
        cmds.append((cmd, cmd_args))
    return cmds

And it's then used in the actual command execution like so:

            command(**(args or {}))

Unless I'm reading that wrong, a call to Fabric like this:

    fab command:key1=val1,key2=val2

would result in:

   command(key1=val1, key2=val2)

And thus command, if defined as "def command(**kwargs):", could do
kwargs.keys() or kwargs.values().

Or am I getting it wrong somewhere? :)

-Jeff




reply via email to

[Prev in Thread] Current Thread [Next in Thread]