On 16 December 2011 13:14, Tisza Gergo <gtisza(a)gmail.com> wrote:
did anyone try creating command line autocompletion
 for bot scripts?
Not that I know of.
I'm interested both in quick and dirty hacks (my current plan is to grep
arg.startswith parameters from the bot code and use them as a more or less
correct argument list)
This sounds like something that will work, although 'arg' might not be used
every time. Should be a good first approach.
and a long-term solution for making pywikipediabot
parameter handling and help generation easy both for the bot programmer
I'm not against this, but there are already some frameworks that do this,
and they are IMO not much clearer than the current system. See, for
instance, the getopt, argparse and optparse modules. (
(although argparse is python 2.7+, and therefore not usable. optparse
should be OK).
So: the module you'd want to write is already there. I'm just not sure if
it's much better.
- easier parameter handling and help text autogeneration
- automatic generation of bash completion files
I agree on these,
- it could pave the way for moving towards a more
double dashes before long arguments and the other usual features
I´m not sure if this is an advantage, as is completely breaks
compatibility. I agree it´s usual in unix, but it´s not necessarily a good
reason to change. Besides, pwb is also used on windows a lot (and under
powershell, single-dash parameters are 'usual').
- it would make it possible to create GUI controls for
the bots, with
auto-generated option fields
GUI controls should work on a higher level, instantiating bot objects
instead of running the bot using the shell, IMO.
What do you think about it? Am I overcomplicating, or
is this worth doing?
In general, I think the bash completion would be very useful. I'm not sure
if rewriting the entire mechanism is useful, nor necessary to achieve bash
completion. I would be inclined to to just use the arg.startswith
mechanism, and to adapt any script that does not conform to that 'standard'.
However, if you actually need the parameter description for some nicer
autocompletion, we would need something nicer - parsing the module.__doc__
wouldn't be a good plan ;-)
In any case: good luck with building the auto-completion. If you need to
change the way the argument parser is implemented in code, I'd suggest
adapting optparse to use 'pwb-style' single dashes. I would suggest not to
change the current parameters unless there is a very strong reason (i.e.
stronger than 'the rest of the *nix world uses double-dashes') to do that.
Merlijn van Deen