[PATCH RFC] shellext: automatically add shell scripts as new commands

Martin Geisler mg at aragost.com
Tue Jan 10 05:14:58 CST 2012


Matt Mackall <mpm at selenic.com> writes:

> On Mon, 2012-01-09 at 22:09 +0100, Martin Geisler wrote:
>> Matt Mackall <mpm at selenic.com> writes:
>> 
>> > - How do we make these things work with the help engine?
>> >
>> > By wrapping some RST in a specially-formatted comment block?
>> 
>> Maybe better by looking for a foo.rst file when we have a
>> foo.something-else file?
>
> Mercurial extensions can be single .py files, why not these? Having
> two files is just an invitation to have install errors and mismatched
> help.

I think extensions written in Python should just follow our normal
standards. I was thinking of scripts in other languages that we wont
have parsers for.

But maybe it's easy enough to parser .sh, .pl, .cmd, ... scripts and
extract the first comment. If so, then I'm all for going that route.

>> > - Can we do anything to facilitate argument parsing?
>> >
>> > It'd be extremely helpful to do some option parsing/validation like
>> > fancyopts does and making sure we have the right number of args.
>> 
>> You mean that the script can declare its arguments and we'll validate
>> them before starting the script? I had expected the script to do that
>> itself.
>
> Oh sure, it's possible to do it that way. But given the tedium of
> doing shell programming right, we can already expect the quality of
> implementation of these shell extensions to be... embarrassing.

True. I looked briefly at how Git does it, and as far as I can see they
have a little shell script infrastructure for common tasks, but command
line arguments are parsed the old fashioned way:

  https://github.com/gitster/git/blob/master/git-pull.sh

Someone please correct me if that's not the code that 'git pull' runs.

-- 
Martin Geisler

aragost Trifork
Professional Mercurial support
http://mercurial.aragost.com/kick-start/


More information about the Mercurial-devel mailing list