zed icon indicating copy to clipboard operation
zed copied to clipboard

support interactive input to tasks

Open andrewbanchich opened this issue 1 year ago • 3 comments

Check for existing issues

  • [X] Completed

Describe the feature

i'd love to create a task like Pull package which allows me to write the name of a package so it can pull / build / some other things.

If applicable, add mockups / screenshots to help present your vision of the feature

No response

andrewbanchich avatar Oct 09 '24 15:10 andrewbanchich

Can you explain your use case, language and environment better?

Generally, tasks already support interactive input, e.g.

{
    "label": "test task with waiting",
    "command": "sh -c",
    "args": [
      "'echo -n \"Create database? [y/N] \"; read -n 1 answer; echo; [ \"$answer\" = \"y\" ] || [ \"$answer\" = \"Y\" ] && echo \"Creating DB...\" || echo \"Aborted\"'"
    ]
  },

on macOS will wait for Y or other input before continuing. Similarly, I can run some Python/Rust task that reads from stdin and it will work.

SomeoneToIgnore avatar Oct 09 '24 16:10 SomeoneToIgnore

Similarly you could use the ZED_SELECTED_TEXT variable to make a task that does something based on a selection. See: Tasks: Variables in the docs.

notpeter avatar Oct 09 '24 19:10 notpeter

Using the selection doesn't work for my case since it's coming from my brain, not a text buffer.

The bash would work, but just would be nice to have a higher level API for this, like:

{
    "label": "pull package",
    "command": "sh -c",
    "inputs": ["PACKAGE", "VERSION"],
    "args": [
      "pull-package $inputs.PACKAGE --version $inputs.VERSION"
    ]
  },

andrewbanchich avatar Oct 09 '24 21:10 andrewbanchich

A minimalist UI component like the one to select the task to spawn would be amazing.

alvgaona avatar Oct 22 '24 20:10 alvgaona

We can ~~steal~~ borrow the implementation approach from VS Code https://code.visualstudio.com/docs/editor/variables-reference#_input-variables

vittorius avatar Feb 15 '25 13:02 vittorius