[PATCH] purge: use opts.get()
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Tue Jun 7 19:15:07 UTC 2016
On 06/01/2016 04:35 AM, Gregory Szorc wrote:
>
>
> On Fri, May 27, 2016 at 7:32 AM, Pierre-Yves David
> <pierre-yves.david at ens-lyon.org <mailto:pierre-yves.david at ens-lyon.org>>
> wrote:
>
> This is not the first time we need to do this, should we grow some
> semi-official API to call a command? (some subset of dispatch with a
> pythonic way of passing argument)
>
>
> I'm not sure what you have in mind. We do have the argument names from
> @command. IIRC dispatch already ensures all CLI arguments have named
> arguments in the function call. Perhaps we'd need to split that out and
> make an API so extensions can call that? But you can't enforce that
> since an extension can get a handle on the command function and call it
> directly. I suppose it's better than nothing.
Yes, splitting dispatch so that one can call something like
callcommand('commit', 'myfile.txt', message="foobar",
user="babar at savannah")
And still have all the dispatch logic apply (except for alias/default).
Right now, you have to call:
dispatch('commit', 'myfile.txt', '--message', "foobar", '--user',
"babar at savannah")
This is vastly unpythonic.
Sure, extension could still grab the handle directly, but they would not
have a good reason to do so anymore.
--
Pierre-Yves David
More information about the Mercurial-devel
mailing list