Insomnia: [Feature Request] – Make 'Copy as curl' configurable

Created on 22 Jun 2019  Â·  8Comments  Â·  Source: Kong/insomnia

  • Insomnia Version: 6.5.4
  • Operating System: Windows 10

Details

Allow users to configure the Copy as curl context menu on requests in a workspace. Ideally we would at least the generation of curl vs powershell at a minimum. However I think there could be a use case of wanting to always copy as any of the httpsnippet targets/clients.

accepted good first issue

Most helpful comment

@jgiovaresco From an approach standpoint, I would say to satisfy this issue, MVP would be _not in a plugin_ and could be scoped to:

  • Change Copy as cURL to Copy As
  • Dialog with dropdown to choose what to copy as (shown on each copy as - this can be improved on later)
  • Remember last option selected for future copies

Then converting the above into a plugin would be the second stage as it does rely on #2678 being in the codebase

All 8 comments

I like the idea of being able to select any of the code generation formats to for an improved "Copy as x" hotkey

I am interested in working on this

@KarthikSiddarth That would be awesome.

I feel like we could add a property to the Settings data model to store it. What do you think about simply storing and showing the last one that was used in the export dialog?

@KarthikSiddarth I don't know if you are still working on this? But I've started to think about how I can tackle this issue on my side.

@develohpanda @nijikokun @DMarby
I have a good idea of how to implement this in Insomnia Core, but I've got another idea: what about extracting the Copy As feature in a plugin?
It seems that there are several plugins that are bundled with Insomnia Core (from what I'm understanding), and we could extract the current feature in a new bundled plugin.

I can see some advantages:

  • "simplify" core codebase by isolating the feature in a dedicated place. This would remove at least 1 props from several React components.
  • we would be able to store the chosen target in the plugin config and prevent "polluting" the settings
  • it should ease the test

Also, I'm wondering if I would need the awesome PR of @nijikokun https://github.com/Kong/insomnia/pull/2678 to add an action on a specific request. 🤔

@jgiovaresco From a product perspective, I like this idea, and aligns with our overall long-term strategy in that we originally wanted with reducing the core codebase footprint and improving the plugin system.

@nijikokun 👌 I will delve into this to see how I can implement this.

I might need some help to understand how those plugins are loaded because for now, it looks like dark magic 😅
And do you think I need the change of https://github.com/Kong/insomnia/pull/2678?

@jgiovaresco From an approach standpoint, I would say to satisfy this issue, MVP would be _not in a plugin_ and could be scoped to:

  • Change Copy as cURL to Copy As
  • Dialog with dropdown to choose what to copy as (shown on each copy as - this can be improved on later)
  • Remember last option selected for future copies

Then converting the above into a plugin would be the second stage as it does rely on #2678 being in the codebase

@nijikokun I've noticed the Generate Code action. This action opens a modal where we can choose the target, and we can copy the generated code in the clipboard (see screenshot below)

I'm wondering if we really need an additional action to "generate code" in the clipboard. 🤔

Screenshot 2020-10-16 at 22 37 11

Was this page helpful?
0 / 5 - 0 ratings