Skip to content

Require environments to be declared before use in conditionals #120

@scizzorz

Description

@scizzorz

As I've started to more heavily parameterize my moldfiles, I've found that one of the initial goals of Mold - being a quick source of "what can I do in this project" - is falling apart. I often have something like the following:

if foo {
  var OBJ = "foo"
}
if bar {
  var OBJ = "bar"
}

if dev {
  var ENV = "dev"
}
if prod {
  var ENV = "prod"
}

recipe deploy {
  $ "foo $ENV $OBJ"
}

Which yields a rather useless default command listing, as simply running mold deploy isn't sufficient; you actually need to run mold deploy -a foo -a prod or some other combination. If environments had to be declared ahead of time, the default listing could also describe them as well.

Another feature this could provide would be to enable some sort of automatic enabling of environments under some conditions? That seems like it's a bit bigger of a feature, though. For example, in most CI tools, the environment variable $CI is automatically declared. Because Mold has no way to check for that, I often use a -a ci flag in CI and the corresponding if ci or if ~ci blocks handle special cases for CI/non-CI.

This particular example also makes me wonder if there would be some way to parameterize the recipe differently, but that's another topic

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions