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: [email protected] http://cz.linkedin.com/in/vlcinsky 2013/2/24 Matthew Honnibal <[email protected]> > 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 > [email protected] > https://lists.nongnu.org/mailman/listinfo/fab-user >
_______________________________________________ Fab-user mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/fab-user
