Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fabfiles With Command Line Arguments

Tags:

python

fabric

Is there a clean way to have your fabfile take command line arguments? I'm writing an installation script for a tool that I want to be able to specify an optional target directory via the command line.

I wrote some code to test what would happen if I passed in some command line arguments:

# fabfile.py
import sys

def install():
    _get_options()

def _get_options():
    print repr(sys.argv[1:])

A couple of runs:

$ fab install
['install']

Done.
$ fab install --electric-boogaloo
Usage: fab [options] <command>[:arg1,arg2=val2,host=foo,hosts='h1;h2',...] ...

fab: error: no such option: --electric-boogaloo
like image 640
Chris Avatar asked May 18 '10 17:05

Chris


1 Answers

I ended up using the per-task arguments. It seems like a better idea than doing unattached command line arguments.

like image 166
Chris Avatar answered Sep 21 '22 17:09

Chris