Skip to content

Support dryrun behavior when executing shell commands #324

@hindman

Description

@hindman

Almost every time I write a script to execute shell commands, I end up with a function that looks roughly like this:

def run(cmd, dryrun=False):
    if dryrun:
        # Just print cmd or maybe return cmd with some other data.
    else:
        # Actually run it with subprocess, typically returning stdout, exitcode, cmd, etc

This sort of thing is very handy for development work and debugging. It is also a useful thing to have if you want to write unit tests for your code.

Our team uses Fabric a lot and I created a module that wraps Fabric in a class that supports dryrun, but this effort was fairly awkward and requires a certain amount of carefulness from users of the class.

Are there plans to include dryrun behavior in Invoke and ultimately in Fabric 2.0? I don't see anything in the docs or invoke codebase so far. I'd be willing to lend a hand, but wanted to get a reality check first.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions