On 16 December 2011 13:14, Tisza Gergo <email@example.com>
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 out the
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 and the
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 linux-like command syntax with
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 reinventing the wheel, 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