danielgtaylor / restish

Restish is a CLI for interacting with REST-ish HTTP APIs with some nice features built-in
https://rest.sh/
MIT License
717 stars 69 forks source link

(Feature Request) - Allow restish to be used in non-interactive mode #238

Open thebauda opened 5 months ago

thebauda commented 5 months ago

Description

Rather than following command line prompts, allow restish to be used in a non-interactive mode where users can pass flags to streamline API configuration and modification.

Background

Our team uses restish to expose proprietary APIs through a CLI written in Golang. Behind the scenes, we configure APIs through restish and wrap the inputs and outputs to conform to our desired user experience. By having restish in a non-interactive format, it will streamline our API onboarding and reconfiguration process where we have to guess what output will be returned, as well as guess where the user's restish.json file is located so we don't have to modify it directly.

loicalleyne commented 3 months ago

I've submitted a pull request which adds an restish/embedded package that allows restish to be imported as a library. It allows for setting a different appname (separate config from restish installed on system), sending an authorization token prefix and token in the function call (new handler added in cli/auth.go), and optionally passsing in io.Writers to redirect cli.Stdout and cli.Stderr. I didn't write any tests for it but I got a branch of my fork working in another CLI app once I fixed the imports. github.com/loicalleyne/restish@embedtest

thebauda commented 2 months ago

Awesome, thank you!