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

Add interpreted go code as an alternative to shell #243

Closed
ddtmachado opened this issue Aug 27, 2019 · 3 comments
Closed

Add interpreted go code as an alternative to shell #243

ddtmachado opened this issue Aug 27, 2019 · 3 comments

Comments

@ddtmachado
Copy link

ddtmachado commented Aug 27, 2019

This is a feature request

Add integration with Yaegi to support interpreted go code on variables / environments and commands.

version: '2'

# Could require custom configuration for the interpreter
go:
  import:
    - "fmt"
    - "os"

env:
  MY_ENV:
    go: fmt.Println("Hello")

tasks:
  my-go-task:
    cmds:
      - go: |
        fmt.Println("MY_ENV:", os.Getenv("MY_ENV"))

I love the idea as it would open so many possibilities for complex scenarios like you could just import your packages and use your API to write or assist in tasks, without having to rely on command binaries.

But I may be completely off and this might not be feasible / doable on Task.dev, just let me know :)

@andreynering andreynering added type: feature A new feature or functionality. proposal labels Sep 1, 2019
@andreynering
Copy link
Member

Hi @ddtmachado, and thank for opening this issue!

FYI: there was some discussion already about allowing plugging more interpreters into Task: #195 (comment).

A couple of comments on this proposal:

First of all, while Task is written in Go and it's more popular between Go devs, it's also used on other contexts. For example, it's also used for generic devops stuff (building Docker images, etc), and I've seen it being used on other languages projects (Python, etc). That said, why allow specifically Go but not, say, Python, Ruby, Lua or other languages with interpreters available in Go?

That said, the reason we use a Shell interpreter is to normalize the behavior between different operation systems (most notably Windows, which doesn't come with a Posix-like shell). Ideally, we wouldn't have any other interpreters shipped with Task since can you already can run other languages by running go run script.go, python script.py, ruby script.rb, etc. You just can't use Task templating features with them just yet.

So, the best proposal so far IMHO is @stephenprater's one here to have something like this:

interpreters:
  python: /usr/bin/env python
  ruby: bundle exec ruby

This way people would be able to plug whatever language they want into Task (but with the con of requiring it to be installed into the system).

@ddtmachado
Copy link
Author

Hello @andreynering

Thanks for taking the time to answer and link to other discussions around this topic.

So, the best proposal so far IMHO is @stephenprater's one

Yes I think @stephenprater proposition is good enough if we could set that at task level.

Feel free to close this issue if you are already tracking that proposal on the v3 roadmap.

@bartdeboer
Copy link

For anyone who's interested. I've built a simple task runner that does exactly this:

https://github.com/bartdeboer/runtask

@pd93 pd93 removed type: feature A new feature or functionality. type: proposal labels Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants