Skip to content

Copy request as cURL to clipboard from the context menu #941

Description

@giemic8

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

There is no quick way to hand a request from Trufos to the terminal or a colleague. The full code generator (#775) covers this eventually, but a lightweight "copy as cURL" needs no modal, no language selector and no new UI surface — it fits into the existing request context menu (Rename / Copy / Delete Request).

Describe the solution you'd like

Add a "Copy as cURL" entry to the request context menu in the sidebar (RequestDropdown), between "Copy Request" and "Delete Request". Clicking it builds a cURL command from the request and writes it to the clipboard, with a success toast.

Generated command:

  • curl -X <METHOD> '<url>' with the URL built from base + query params.
  • One -H 'Key: value' per active header.
  • Body:
    • Text body: --data-raw '<content>' (content read from the request body file via the existing IPC stream; missing/empty body file → no data flag). Adds -H 'Content-Type: <mimeType>' when no active Content-Type header is set.
    • File body: --data-binary @'<path>' when a file path is set.
    • Form-data: -F 'key=value' / -F 'key=@path' per active field.
  • Values are single-quote shell-escaped (''\''), multi-part commands are joined with \ line continuations for readability.
  • Template variables ({{...}}) are copied unresolved — the command is meant to be portable and must not leak resolved secrets.

Describe alternatives you've considered

Acceptance criteria

  • "Copy as cURL" appears in the request context menu and writes the command to the clipboard.
  • Active-only headers, correct shell escaping, all three body types handled.
  • Works for requests whose body file does not exist yet (never opened).
  • Success feedback via toast; failures surface via the existing error handler.
  • Unit tests for the command builder and the menu action.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestfrontendFrontend related task

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions