Skip to content

CLI-4Postman is a GO command line interface (CLI) for Postman

License

Notifications You must be signed in to change notification settings

joakim-ribier/gcli-4postman

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CLI-4Postman

Go Report Card Software License Go Reference

CLI-4Postman is a GO command line interface (CLI) for Postman based on go-prompt awesome library.

Usage - CMD - Releases - How to Install - Thanks - License

Usage

$ ./gcli-4postman --secret {your-secret} --mode admin --home /home/{user}/data/gcli-4postman

Option Description
--home /home/{user}/data/cli-4postman To define the root folder or directly by adding a new environment variable $GCLI_4POSTMAN_HOME.
--log /path/app.log To choose the path of the log file (by default ./gcli-4postman.log).
--mode admin To select the CLI execution mode (userby default). The admin mode is used to build the README.md and enable/disable the secure mode.
--secret {your-secret} To encrypt (or not) data on the disk. By default Postman does not encrypt data during export (even environment passwords...).

To get started quickly, export collections from a Postman account and add them on the $GCLI_4POSTMAN_HOME folder:

  • $GCLI_4POSTMAN_HOME
    • Personal (workspace)
      • github.collection.json (collection)
      • postman.collection.json (collection)
      • localhost.env.json (environment)
      • prod.env.json ...
    • {My Company} (new workspace)
      • ...

#how-to-use#

CMD

The CLI is handled by a prompt completer which tries to get the correct suggestions. To optimize the list of suggestions from the prompt completer, it is possible to combine && and || operators.

  • {a single value} only matches with the left side of the suggestion {Suggest.Text}.
  • {value}&&{value} matches the left value with the {Suggest.Text} AND the right side with the {Suggest.Description}.
  • {value}||{value} matches the left value with the {Suggest.Text} OR the right side with the {Suggest.Description}.
Command Option Description
load :l Load a collection - Postman API HTTP requests format - from the local disk.
# :l my-collection
env :e Select the collection execution environment.
# :e localhost
http :h Execute a request from the collection - !! BE CAREFUL TO THE ENVIRONMENT !!
# :h -u GET../users/findByName {{id}} "Joakim Ribier" {{x-organisation}} "GitHub" --pretty
to not send the header parameter, add --delete after the {{x-organisation}}
-m - filter requests by method (GET, POST...)
-u - find a request to execute
-history - find a previous request
# :h -history GET../users/findByName#1 --pretty
--search {pattern} - find data in the response using tidwall/gjson awesome lib
more details on https://github.com/tidwall/gjson
--pretty - display a beautiful HTTP json response
--full - display the full response (not limited to 5000 characters)
--save {/path/file.json} - save the full body response in a file
--reset - reset the collection history requests
display :d Display API requests of the current loaded collection.
# :d --search users
--search {pattern} - API requests full-text search
postman :p Connexion to a Postman account to sync the workspaces on the local disk.
# :p --apiKey {KEY} -sync {workspace}
--apiKey - API keys settings
-workspace - display the remote workspaces linked to the {API_KEY}
-sync {workspace Id/Name} - sync one of the workspaces locally
settings :s Available settings (or actions) on CLI-4Postman
# :s -secure-mode enable --secret {secret}
-update-readme - update the README from help documentation // --mode admin
-secure-mode enable - enable secure mode by adding (or update) a new secret --secret {secret} // --mode admin
-secure-mode disable - disable secure mode !! NOT RECOMMENDED !! // --mode admin
exit :q Exit the application.
# :q

#how-to-use#

The how-to-use part is directly generated from the application in ADMIN mode.

$ ./gcli-4postman --mode admin
...
$ {collection} >> {no-env} # settings -update-readme
>> Would you like to update README (Yes/No) : Yes
> README.md updated!

Releases

v0.1.x

  • [] Implement tests...
  • [] Refactor the collection view (replace the tree by a table)
  • [] Implement the environment view
  • [] Improve search mode in the response API request
  • [] Improve the implementation using the go-utils library
  • [] Refactor prompt action to seperate execution code in its own prompt executor
  • [] ...

v0.1.0

  • Implement the first CLI-4Postman code base
    • Import collections and environments from Postman account (API_KEY)
    • Search and execute an API request on a specific environment
    • Display a collection
    • Historise API requests
    • Historise global commands
    • Encrypt / Decrypt data on disk (--secret my-secret)
    • Update README.md directly from a prompt-action
    • Help
  • Implement the go-utils library

How To Install

go install -v github.com/joakim-ribier/gcli-4postman/cmd/gcli-4postman@latest

Thanks

License

This software is licensed under the MIT license, see License for more information.

About

CLI-4Postman is a GO command line interface (CLI) for Postman

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages