erlang / rebar3

Erlang build tool that makes it easy to compile and test Erlang applications and releases.
http://www.rebar3.org
Apache License 2.0
1.71k stars 517 forks source link

Calling {appup, clean} from an alias #1940

Closed tothlac closed 6 years ago

tothlac commented 6 years ago

I have a plugin, which has several modules using different names.

For example appup plugin implements clean, compile, generate, and so on.

In the implementation of the plugin command modules, the namespace is always the same (appup), but the name is different (clean, compile, generate).

My problem is that I would like use them in aliases, like:

{alias, call_release, [‘appup clean’, ‘appup compile’, release]}

This is the only way I’ve found to call the ‘appup clean’ command.

Calling it rebar3 complains:

===> Command 'appup clean' not found

I know the name passed from rebar_prv_alias to rebar_prv_do:do_tasks/2 should be clean, and the namespace defined in the state, should should be ‘appup’.

Unfortunately rebar_prv_alias passes default namespace in rebar_state to rebar_prv_do:do_tasks/2. Is there any solution for this?

So basically the question is that how can I call rebar3 appup clean from an alias, or any module:do function which implemented not in the default namespace.

aboroska commented 6 years ago

Might be worth to note that the following fails as well (on latest master):

{alias, [{myalias, [{plugins, "list"}]}]}.

So, what would be a correct alias config for rebar3 do plugins lists for example? It might be a bug in how alias arguments are parsed.

ferd commented 6 years ago

I think that the current alias provider does not support namespaced commands. Support needs to be added for that, probably under the format {alias, [{myalias, [{{plugins, list}, ""}]}]}. or something

tothlac commented 6 years ago

It looks like it is actually the same error: rebar3 plugins list uses the plugins namespace and the command is list.

tothlac commented 6 years ago

Currently the following two clauses are supported:

The following two cases should be supported:

Would this format be also fine for you?

ferd commented 6 years ago

yeah I think that would make sense as well.

tothlac commented 6 years ago

It looks like this small modification does the trick: https://github.com/tothlac/rebar3/commit/22ee27d99bb16ccf58e1080f89795135ad18cf9c