warpdotdev / Warp

Warp is a modern, Rust-based terminal with AI built in so you and your team can build great software, faster.
https://warp.dev
Other
20.25k stars 337 forks source link

Ability to escape {{}} in Workflows #3352

Open tomaley opened 11 months ago

tomaley commented 11 months ago

Discord username (optional)

No response

Describe the solution you'd like?

Many of the CLI tools I frequently use support GoTemplate formatting of output. While powerful and useful, these templates are a pain to craft each time they're needed so I would love to be able to save them to workflow... but the mustache syntax conflicts with the 'arguments' feature of workflow.

A command I used today:

ibmcloud cr image-list --format '{{if eq .Namespace "personal-dev"}}{{.Repository}}:{{.Tag}}{{end}}' | xargs ibmcloud cr image-rm

to clear out all images in my 'personal-dev' registry namespace would be a prime candidate to be saved away in workflow with the 'personal-dev' element being an argument so I can apply this to namespaces in a parameterized fashion. The issue is that the command cannot be saved because it wants to make `{{end}}` an argument.

Kubectl commands supporting `-o go-template` have the same issue and again make prime candidates for parameterized workflow entries.

Is your feature request related to a problem? Please describe.

A command I used today:

ibmcloud cr image-list --format '{{if eq .Namespace "personal-dev"}}{{.Repository}}:{{.Tag}}{{end}}' | xargs ibmcloud cr image-rm

to clear out all images in my 'personal-dev' registry namespace would be a prime candidate to be saved away in workflow with the 'personal-dev' element being an argument so I can apply this to namespaces in a parameterized fashion. The issue is that the command cannot be saved because it wants to make `{{end}}` an argument but that is part of the GoTemplate 'if' directive.

Additional context

No response

How important is this feature to you?

3

Warp Internal (ignore) - linear-label:770f6576-d6c0-4e4f-a259-fc64b5156087

None

dannyneira commented 11 months ago

Thanks for this feature request! There is a somewhat related issue you can track here: https://github.com/warpdotdev/Warp/issues/3205

In essence, when you have two arguments side by side with no character/space in between, the workflows don't work as intended. (i.e. echo {{arg1}}{{arg2}})

Please add a :+1: to the original post at the top to signal that you want this feature, and then hit the subscribe button if you'd like to be notified.

zheng commented 11 months ago

Thanks for this request! I'm thinking what the product should do is allow you to escape if what you want is the explicit moustache. It looks like the standard syntax in HTML would be to do {{{end}}}. Does that seem like the right approach to you?

tomaley commented 11 months ago

@zheng that sounds perfectly reasonable to me

kevin-lucas-simon commented 9 months ago

I have this issue too with some Docker related commands in my Warp workflows. For example docker stats --format "table {{.Name}} {{.CPUPerc}}" for displaying the CPU stats of my containers.

kar0v commented 6 months ago

Let me also add my pain point - I've been unable to transfer all my iTerm snippets to Warp, which amazes me as there is no way to save plain text commands. I've been struggling with docker history --no-trunc --format "{{.ID}}: {{.CreatedBy}}". Can you add a boolean checkmark somewhere to store the workflow as plain text and to be able to save that workflow?

0Knot commented 5 months ago

You can take a detour and enter DOCKER_TEMPLATE=$(echo '{{ json .Mounts }}') in the linux shell

Then use the following syntax in the workflow

docker inspect --format "$DOCKER_TEMPLATE" {{DOCKER_IMAGE}} | python3 -m json.tool

I hope the official can optimize this syntax

tukusejssirs commented 3 days ago

I am also experiencing this bug.

IMHO this is what Warp should do:

Another way to accomplish this is to select a part of the code and click a button (e.g. Make a variable) or press a keyboard shortcut (e.g. Alt+V).