fab-user
[Top][All Lists]
Advanced

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

Re: [Fab-user] Have you considered using the plac syntax for command lin


From: Jeff Forcier
Subject: Re: [Fab-user] Have you considered using the plac syntax for command line arguments?
Date: Sun, 24 Feb 2013 15:21:42 -0800

Hi guys,

Fabric 2.x and its standalone runner (Invoke; see
http://docs.fabfile.org/en/latest/roadmap.html) are using a custom CLI
parser to allow classic Unix style flags while preserving Fabric's
"make-like" multiple task invocation.

So using plac directly isn't in the cards. However, I'm pretty sure
that once it's complete there will be a plac (and paver and etc)-like
mode where you can declare your arguments' types explicitly.
(Currently, the default mode is to infer typing implicitly, though the
software will not be 1.0 ready until said explicit option is
available.)

Best,
Jeff

On Sun, Feb 24, 2013 at 3:12 PM, Jan Vlčinský (TamTam Research)
<address@hidden> wrote:
> Hi Mathew and fab-user list
> I have to second, that plac is great option to provide fully featured
> command line interface, in fact, this became standard in my work.
> Fab is another one.
>
> Sharing the concept would be great to me.
>
> (saying that, I am aware, I have limited knowledge of all related
> implications to fab)
>
> With best regards
>
> Jan
>
> Jan Vlčinský
> TamTam Research s.r.o.
> Slunečnicová 338/3, 734 01 Karviná Ráj, Czech Republic
> tel: +420-597 602 024; mob: +420-608 979 040
> skype: janvlcinsky; GoogleTalk: address@hidden
> http://cz.linkedin.com/in/vlcinsky
>
>
> 2013/2/24 Matthew Honnibal <address@hidden>
>>
>> I noticed this in the "fab usage and options" docs:
>>
>> "Additionally, since this process involves string parsing, all values
>> will end up as Python strings, so plan accordingly. (We hope to
>> improve upon this in future versions of Fabric, provided an intuitive
>> syntax can be found.)"
>>
>> When I started using fabric, one thing I noticed was that I missed the
>> interfaces I was getting from the plac library:
>> http://plac.googlecode.com/hg/doc/plac.html
>>
>> An example from the docs:
>>
>>  @plac.annotations(
>>     db=plac.Annotation("Connection string", type=SqlSoup),
>>     header=plac.Annotation("Header", 'flag', 'H'),
>>     sqlcmd=plac.Annotation("SQL command", 'option', 'c', str,
>> metavar="SQL"),
>>     delimiter=plac.Annotation("Column separator", 'option', 'd'),
>>     scripts=plac.Annotation("SQL scripts"),
>>     )
>> def main(db, header, sqlcmd, delimiter="|", *scripts):
>>     "A script to run queries and SQL scripts on a database"
>>     yield 'Working on %s' % db.bind.url
>>
>>     if sqlcmd:
>>         result = db.bind.execute(sqlcmd)
>>         if header: # print the header
>>             print delimiter.join(result.keys())
>>         for row in result: # print the rows
>>             print delimiter.join(map(str, row))
>>
>>     for script in scripts:
>>         db.bind.execute(open(script).read())
>>         print 'executed %s' % script
>>
>> if __name__ == '__main__':
>>     plac.call(main)
>>
>> If run with no or invalid arguments, it automatically generates the
>> help message:
>>
>> usage: dbcli.py [-h] [-H] [-c SQL] [-d |] db [scripts [scripts ...]]
>>
>> A script to run queries and SQL scripts on a database
>>
>> positional arguments:
>>   db                    Connection string
>>   scripts               SQL scripts
>>
>> optional arguments:
>>   -h, --help            show this help message and exit
>>   -H, --header          Header
>>   -c SQL, --sqlcmd SQL  SQL command
>>   -d |, --delimiter |   Column separator
>>
>> Now, there's any number of reasons why this might not be the right
>> approach for fabric, or why other people might think it's actually
>> awful. But I find it very nice, so I just wanted to check you were
>> aware of it as a potential solution.
>>
>> _______________________________________________
>> Fab-user mailing list
>> address@hidden
>> https://lists.nongnu.org/mailman/listinfo/fab-user
>
>
>
> _______________________________________________
> Fab-user mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/fab-user
>



-- 
Jeff Forcier
Unix sysadmin; Python/Ruby engineer
http://bitprophet.org



reply via email to

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