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

Matt Mackall mpm at selenic.com
Tue Jan 10 18:22:42 UTC 2012


On Tue, 2012-01-10 at 12:14 +0100, Martin Geisler wrote:
> 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.

I think if we encounter a comment that looks like:

# HELP:

..then we read the rest of the comment block, strip off "#" (or perhaps
'!') and treat it as RST.

> >> > - 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.

Really, this is what the competition's code looks like? Now I feel a
little sad.

-- 
Mathematics is the supreme nostalgia of our time.





More information about the Mercurial-devel mailing list