themill / wiz

Environment management framework
GNU Lesser General Public License v3.0
45 stars 4 forks source link

Simplify process to associate command alias with another definition #49

Open buddly27 opened 4 years ago

buddly27 commented 4 years ago

It is currently possible to override commands from a definition within another registry to customize the command alias, or associate a command alias with a particular definition version.

For instance, we could have the following definition to launch foo:

{
    "identifier": "foo",
    "version": "2.3.0",
    "command": {
        "app": "FooExe"
    }
}

We can execute the app command alias using wiz use or wiz run:

>>> wiz use foo -- app
>>> wiz run app

We could then add another definition in another registry to override the app command alias:

{
    "identifier": "foo-extended",
    "command": {
        "app": "FooExe --option bar"
    },
    "requirements": [
        "foo ==2.3.0"
    ]
}

Therefore, the wiz run command would then run app as defined in foo-extended while still associating it with foo==2.3.0.

However, it can be quite cumbersome and error-prone to write the entire command alias when the goal is not to customize it, but only to associate it with another definition version. For instance, the following definition will ensure that foo==1.2.3 is used instead of foo==2.3.0 when running the wiz run command:

{
    "identifier": "foo-extended",
    "command": {
        "app": "FooExe"
    },
    "requirements": [
        "foo ==1.2.3"
    ]
}

We could add a new inherited-commands keyword instead to cover this case:

{
    "identifier": "foo-extended",
    "inherited-commands": ["app"],
    "requirements": [
        "foo ==1.2.3"
    ]
}
buddly27 commented 4 years ago

use-commands might be a better name as "inherited" could lead to confusion with the graph dependency tree.