Julien-cpsn / ATAC

A simple API client (postman like) in your terminal
https://atac.julien-cpsn.com/
MIT License
1.22k stars 64 forks source link

Import from cURL (feature) #48

Open vn971 opened 2 months ago

vn971 commented 2 months ago

TL&DR; add the ability to import cURL please!

Full explanation: It would be a useful feature to be able to import a request from cURL. Currently, browsers such as Firefox and Chromium allow you to select a request and click Copy > Copy as cURL. This is very convenient, because you can immediately start altering your request in CLI if you want.

Native support for that in atac could look like an import feature, upon which the cURL command line would be read (from user's input), parsed and transformed into an atac request.

Thank you for the tool!

Julien-cpsn commented 2 months ago

Hello!

That is totally a great idea, if the curl has to be inside a file is it ok to you?

vn971 commented 2 months ago

@Julien-cpsn that'd definitely be appreciated!

To be 100% transparent, the ideal case would be to paste the code in some kind of input text area. However, reading from a file is definitely a good start, and the UX can probably be polished when there's broader demand for this feature. So I think it's definitely a good feature to have now!

P.S. Also, since atac is a terminal client, some people may use the tool remotely. It's not easy for me to think of these situations, but I imagine situations where a file input would be preferred could exist. To be frank, I'm not sufficiently aware of TUI best practices. For me personally, either approach would be good ^^

Julien-cpsn commented 2 months ago

@vn971 hmm Ok I see, and what about the app trying to get what's on your clipboard?

vn971 commented 2 months ago

@Julien-cpsn For me personally, this may not always work as it'd be impossible in e.g. a remote scenario, or if atac is running in a sandboxed environment with no graphical session access. I don't really know TUI best practices though. Is a little bit of graphical APIs usage considered okay, for e.g. for the clipboard, or mouse clicks? Again for me, a text box or file import would be ideal

Thanks for considering!

Julien-cpsn commented 2 months ago

@Julien-cpsn For me personally, this may not always work as it'd be impossible in e.g. a remote scenario, or if atac is running in a sandboxed environment with no graphical session access. I don't really know TUI best practices though. Is a little bit of graphical APIs usage considered okay, for e.g. for the clipboard, or mouse clicks? Again for me, a text box or file import would be ideal

Thanks for considering!

Text boxes and mouse events are really things to avoid. When speaking of TUI UX, the goal is to make it the simplest way. E.g. if a feature involves many graphical elements that are not needed or what I personally call crackhead knowledge (you haven't read line 301 part 5 of the documentation ☝️🤓)

In our case: The simplest would be a file imported with the import command that already exist

So I think we'll go with that

jwtly10 commented 2 months ago

Hey @Julien-cpsn if its alright with you, I'd like to work on this.

I've already made a bit of a start, and have an initial implementation done.

I will raise PR and get some feedback as I may have a few questions.

Thanks

Julien-cpsn commented 2 months ago

@jwtly10 that's very great! Thanks

I have been working on pre and post-request scripts, and request export for the whole day