Fabric: Improve docs; add example context managers

Created on 27 Sep 2018  路  2Comments  路  Source: fabric/fabric

The documentation shows how to execute a command with a particular code_dir

c.run("cd {} && git pull".format(code_dir))

Please change the example to use the cd() context manager. I have not idea how to do that.

http://www.fabfile.org/upgrading.html#actual-remote-steps

Most helpful comment

@mandarvaze cd is implemented with remote run. Some example in the documentation is what the OP is asking for. @klahnakoski this is how its done.

@task
def cd_example(ctx):
    ctx.run("pwd")
    with ctx.cd("/etc"):
        ctx.run("pwd")

All 2 comments

The document referred above clearly says :

with cd is not fully implemented for the remote side of things

@mandarvaze cd is implemented with remote run. Some example in the documentation is what the OP is asking for. @klahnakoski this is how its done.

@task
def cd_example(ctx):
    ctx.run("pwd")
    with ctx.cd("/etc"):
        ctx.run("pwd")
Was this page helpful?
0 / 5 - 0 ratings

Related issues

bitprophet picture bitprophet  路  4Comments

amezin picture amezin  路  5Comments

peteruhnak picture peteruhnak  路  4Comments

haydenflinner picture haydenflinner  路  5Comments

shadyabhi picture shadyabhi  路  5Comments