lechuckroh / task-intellij-plugin

IntelliJ IDEA plugin for go-task run configuration
14 stars 1 forks source link

allow configuration of task variables #3

Closed mkyc closed 2 years ago

mkyc commented 2 years ago

Hi, amazing plugin!

I'd like to run task with variables i.e.,

task mytask SOME_VARIABLE=some-value
lechuckroh commented 2 years ago

@mkyc No problem!!

lechuckroh commented 2 years ago

@mkyc You can download updated version from https://github.com/lechuckroh/task-intellij-plugin/releases/tag/v1.3.0 before publicly available

mkyc commented 2 years ago

@lechuckroh it does work with environment variables syntax ❀️

version: '3'

env:
  TEST: test

tasks:
  print:
    desc: echo TEST env
    cmds:
      - echo TEST=$TEST

Screenshot 2022-01-15 at 22 07 11

task --taskfile /lalala/Taskfile.yml print
TEST=test2
task: [print] echo TEST=$TEST

Process finished with exit code 0

It does not work with variables syntax though.

version: '3'

vars:
  TEST: test

tasks:
  print:
    desc: echo TEST env
    cmds:
      - echo TEST={{.TEST}}

Screenshot 2022-01-15 at 22 07 11

task --taskfile /lalala/Taskfile.yml print
TEST=test
task: [print] echo TEST=test

Process finished with exit code 0

That solves my issue for sure, but I guess variables syntax would be nice to have as well.

Great job!

lechuckroh commented 2 years ago

@mkyc

In my environment (Mac + zsh), variables syntax works as expected.

task --taskfile /lalala/Taskfile.yml print
TEST=test2
task: [print] echo TEST=test2

Process finished with exit code 0

Since some shells don’t support above syntax to set environment variables (Windows) tasks also accepts a similar style when not in the beginning of the command.

It seems your shell doesn't support environment variables. 😒

I'll reopen this issue and working on your case..

Thank you for your reporting. πŸ‘

mkyc commented 2 years ago

@lechuckroh that is interesting.

With code

version: '3'

vars:
  TEST: test

tasks:
  print:
    desc: echo TEST env
    cmds:
      - echo TEST={{.TEST}}

I get directly in shell:

➜  p git:(mkyc/b1) βœ— TEST=test2 task print
task: [print] echo TEST=test
TEST=test
➜  p git:(mkyc/b1) βœ— task print TEST=test2
task: [print] echo TEST=test2
TEST=test2
➜  p git:(mkyc/b1) βœ— echo $SHELL
/bin/zsh
lechuckroh commented 2 years ago

@mkyc Oops!! sorry.. I omitted vars: block in my Taskfile.yml.

Now I got the same output with you.. πŸ˜ƒ

lechuckroh commented 2 years ago

@mkyc You can download v1.3.1 from https://github.com/lechuckroh/task-intellij-plugin/releases/tag/v1.3.1

task --taskfile /foo/Taskfile.yml print TEST=\"test2\" "TEST2=\"foo bar\""
version: '3'

vars:
  TEST: test

tasks:
  print:
    cmds:
      - cat Taskfile.yml
      - echo TEST={{.TEST}} TEST2={{.TEST2}}
TEST=test2 TEST2=foo bar
task: [print] cat Taskfile.yml
task: [print] echo TEST="test2" TEST2="foo bar"

Process finished with exit code 0

Now it works as expected!!

mkyc commented 2 years ago

Works perfectly right now πŸ‘

With code:

version: '3'

env:
  TEST1: test

vars:
  TEST2: test

tasks:
  print:
    desc: echo TEST env
    cmds:
      - echo TEST1=$TEST1
      - echo TEST2={{.TEST2}}

and configuration:

Screenshot 2022-01-16 at 15 22 55

I get output as expected:

task --taskfile /lalala/Taskfile.yml print TEST2=\"test2\"
task: [print] echo TEST1=$TEST1
task: [print] echo TEST2="test2"
TEST1=test1
TEST2=test2

Process finished with exit code 0

So from that perspective all looks cool, thank you!

Two more suggestions but rather UI related:

  1. if that is possible then window to edit variables same as environment variables would be nice.
  2. I would move "Variables" input under "Variables" label same as you did with environment variables.
Screenshot 2022-01-16 at 15 26 35

Anyways great job!

lechuckroh commented 2 years ago

@mkyc

  1. if that is possible then window to edit variables same as environment variables would be nice. Environment variables editor is a built-in component, but variable editor requires custom editor.

  2. I would move "Variables" input under "Variables" label same as you did with environment variables. This will be resolved when custom editor is implemented.

Thank you for greate your feedbacks. ❀️

I'll continue on another issue, and close this issue.