Skip to content
This repository was archived by the owner on Oct 17, 2020. It is now read-only.
Giovanni Farfán B edited this page Oct 15, 2020 · 15 revisions

shTTP

Simple HTTP API development environment by command line.

Command definition

Command Execution - Request Command Execution - Flow

Command execution

Command usage: ./<file>[.sh] <command> [<manage-option>]* [<request-option>]* [--help] [<add-on-option>]*

Command options

Option Description Parameters Scope Example
--list Displays the list (all functions defined into main script) Manage ./gist_comments --list
--envs Displays all environments based on configuration files Manage ./gist_comments --envs
--copy <env-from> <env-to> Copies the environment configuration and credentials files. Must exist the from configuration files. If already exist the to files those will be replaced. If is required to copy from default environment, the first parameters must contain default env-from: Environment from
env-to: Environment to
Manage .gist_comments --copy default stage
--del <env> Removes the selected environment: configuration and credentials files. If is required to remove default environment, the parameter must contain default Manage ./gist_comments --del stage
--get <key-name> Displays the config value by key from ws/config[.<env>].json key-name: Config key Manage ./gist_comments --get name
--add <key-name> <value> <sec> Adds new key-value to ws/config[.<env>].json key-name: Config key
value: Config value
sec (optional):
-h (hidden mode, in ws/.vlt)
-s (public mode, in ws/config[.<env>].json)
Manage ./gist_comments --add name "Lorem Ipsum"
--remove <key-name> Removes the key-value from ws/config[.<env>].json key-name: Config key Manage ./gist_comments --remove name
--keys Displays all keys from ws/config[.<env>].json file Manage ./gist_comments --keys
--part <part> <value> <desc> Adds new credential part to ws/credentials[.<env>].json and ws/.vlt (hidden). Credential option is required (--cred) to execute correctly. part:
-u (username alias)
-p (password alias)
-e (type alias)
-t (token alias)
-k (key alias)
-c (client alias)
-s (secret alias)
-i (PIN alias)
value: Part value
desc (optional): Description of the credential part
Manage ./gist_comments --cred user-credential --part -u username
--creds Displays all credentials ids from ws/credentials[.<env>].json Manage ./gist_comments --creds
--cred-keys <credential> Displays all keys from ws/credentials[.<env>].json file for a specific credential credencial: Credential name Manage ./gist_comments --cred_keys user-credential
--clean Cleans up all output files output/* Manage .gist_comments --clean
--env <env> Sets the environment for script by changing configuration and credentials files: ws/config[.<env>].json and ws/credentials[.<env>].json env: Environment name Manage
Request
./gist_comments --env stage
--cred <credential> Sets the credential for script by updating _shttp_auth_credential credential: Credential name Manage
Request
./gist_comments --cred user-credential
--curl <body-opt> Displays the related cURL command for the input command body-opt (optional):
-f (show the body as filename only, this is the default)
-c (show the body as content)
Request ./gist_comments command --curl
--set <key-name> <value> Sets a temporal key-value config. This won't saved to ws/config[.<env>].json key-name: Config key
value: Override config value
Request ./gist_comments command --set name "Override value"
--local <port> Sets variables to local execution: _shttp_protocol="http" and _shttp_domain="localhost:<port>" port (optional): Port number (default 80) Request ./gist_comments command --local
--port <port> Sets value to port variable (default 8080) port: Port number Request ./gist_comments command --port 80
--auth-basic <credential> Sets mode to _shttp_auth_mode="BASIC" and assign the credential credential: Credential name Request ./gist_comments command --auth-basic user-credential
--auth-token <credential> Sets mode to _shttp_auth_mode="TOKEN" and assign the credential credential: Credential name Request ./gist_comments command --auth-token user-credential
--auth-skip Sets mode to _shttp_auth_mode="SKIP" when authorization mode is not required Request ./gist_comments command --auth-skip
--times <value> Sets the number of executions required for the request in _shttp_request_times value: Number of executions Request ./gist_comments command --times 5
--open Sets _shttp_editor_command with value defined on editorCommand config from ws/settings.json. This causes to execute _shttp_editor_command Request ./gist_comments command --open
--mock Sets to enable the mock flag _shttp_mock_enabled Request ./gist_comments command --mock
--help Displays the help message Manual ./gist_comments --help
--<custom> Add-on option (only applies if and extension file exists in ext directory) defined in extension file defined in extension file ./gist_comments --<custom>

Options scopes

Scope Description
Manage Previous to request execution
Request Affect request execution
Manual Help content

Environment variables

Variable Description
SAVED_LOGS true for saved logs on /tmp/_shttp_basename.yyyy-mm-dd.log otherwise logs only will print by echo function. Default false
DEBUG_MODE true for show default debug logs for internal functions otherwise debug log is skipped. Default false
CHECK_DEPENDENCIES true for check if cURL or jq are already installed otherwise check is skipped. Default false