ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-list
python-list
Re: Arg decoding with a template?
by David Bolen other posts by this author
Aug 7 2001 5:04AM messages near this date
Arg decoding with a template? | Re: Arg decoding with a template?
jimd@[...].org (Jim Dennis) writes:

>   Someone in this thread mentioned the convenience of '?-completion'
>   on *switches* as well as filenames.  Of course in the latest versions
>   of the popular UNIX/Linux shells there is support for "programmable 
>   completion."  However, it would be difficult to make that work with
>   arbitrary command arguments.  I suppose one could emulate it with 
>   a couple of features:

Well, in the system I've used (TOPS-20 native, or the CCMD C library
from Columbia for *nix systems), there's a fundamental difference to
how parsing is handled from something like getopt - or even readline.
Instead of handling a complete set of parse tables to a single parser
entry point, the code to handle parsing was itself broken out into
sections and dynamically executed as a line was parsed (or reparsed).
So not only could you build dynamic tables just prior to parsing
something (so you could vary the options for example), but some
automatic parsing functions would dynamically construct possible
values - such as that used for a filename.

>   	For each (known) command: 
>  		Build a list of known switches

In effect, rather than doing the above, you could set it up to only
build switch completions in a lazy fashion - only if the user started
to enter an option, or used a portion of a command that triggered a
particular set of options.  The code would be called as the parser
traversed that portion of the command line.

Now, in reality, most of the parsing functions did have pre-existing
static definitions, but they still only fed those definitions to the
parser a bit at a time, as those functions invoked the parser when
previous parsing reached them.

Definitely more work in terms of writing parsing code, but the end
result was probably the best interactive command line I can think of.

--
-- David
-- 
/----------------------------------------------------------------------- \               Dav
id Bolen            \   E-mail: db3l@[...].com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \--------------------
---------------------------------------------------/
-- 
http://mail.python.org/mailman/listinfo/python-list
Thread:
Dale Strickland-Clark
David Bolen
Jim Dennis
Marcin 'Qrczak' Kowalczyk
Chui Tey
David Bolen
Hans-Joachim Widmaier
Hans-Joachim Widmaier
Skip Montanaro
Quinn Dunkan
Dale Strickland-Clark
David Bolen
Steve Holden
David Bolen
Alex Martelli
Dale Strickland-Clark
Dale Strickland-Clark
Skip Montanaro
David Bolen
Peter Wang
Steve Holden
David Bolen
Steve Holden
Skip Montanaro

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved