[PATCH RFC] shellext: automatically add shell scripts as new commands
Kevin Bullock
kbullock+mercurial at ringworld.org
Tue Jan 10 10:46:14 CST 2012
On Jan 10, 2012, at 5:14 AM, 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.
It would likely be equally easy to parse out a variable assignment ("HGOPTS=..."), which would expose the same information to the script itself. Especially useful if we expose some argument-parsing niceties.
I'd gladly bang out parsing for Ruby (and could do Perl too).
pacem in terris / мир / शान्ति / سَلاَم / 平和
Kevin R. Bullock
>>>> - 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/
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20120110/1cbbb8dd/attachment.html>
More information about the Mercurial-devel
mailing list