norskeld / arx

Simple and user-friendly command-line tool for declarative scaffolding.
MIT License
9 stars 0 forks source link

feat: implement conditional execution of actions #16

Open norskeld opened 8 months ago

norskeld commented 8 months ago

Description

It would be nice to be able to run actions conditionally, e.g. based on user input from prompt actions or depending on the user OS (#11 probably should be closed in favor of this feature, but I'm not sure).

Example

actions {
  confirm "should_commit" {
    hint "Whether to stage and commit everything on finish"
    default false
  }

  number "magic_number" {
    hint "Enter magic number"
  }

  run when="should_commit == true && (magic_number == 42 || magic_number == 420)" r#"
    git add .
    git commit -S -m 'chore: init repository'
  "#
}

Notes

norskeld commented 4 months ago

A better idea would be to use CEL interpreter. This way we don't need to reinvent the wheel.