Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement conditional execution of actions #16

Open
norskeld opened this issue Mar 5, 2024 · 1 comment
Open

feat: implement conditional execution of actions #16

norskeld opened this issue Mar 5, 2024 · 1 comment
Assignees
Labels
feat New feature or request

Comments

@norskeld
Copy link
Owner

norskeld commented Mar 5, 2024

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

  • I'll need to implement a simple expression parser (with precedence and grouping) and evaluator.
  • It'd be a good idea to add a distinct prompt for numbers. Done.
@norskeld norskeld added the feat New feature or request label Mar 5, 2024
@norskeld norskeld self-assigned this Mar 5, 2024
@norskeld
Copy link
Owner Author

norskeld commented Jul 15, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant