8000 GitHub - gab1618/lapse: HTTP CLI focused on UX and git-heavy workflows · GitHub
[go: up one dir, main page]

Skip to content
< 7FFF header class="root__q6pgdo HeaderMktg header-logged-out fullWidth__R5BAbe" role="banner" data-marketing-header="true" data-color-mode="dark" data-light-theme="light" data-dark-theme="dark">

Navigation Menu

gab1618Public

About

HTTP CLI focused on UX and git-heavy workflows

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Lapse

Logo

License: GPL v3+

Http CLI focused on UX and git-heavy workflow

Summary

Making requests from CLI can be very intimidating. I myself have tried some tools, and I always ended up falling back to Insomnia.

Lapse's design is built on top of files that will define the whole behavior. Not only this simplifies the whole proccess of using it, but it also lets you use your favorite tools.

Features

  • Http requests
  • Multipart/form requests
  • Environments and variables
  • Secrets
  • Lua scripts and interpolation

The anatomy of a Lapse space

├── .lapse
├── env
│   ├── hooks.json
│   ├── secrets.json
│   ├── config.json
│   ├── variables.json
│   └── other-env
│       ├── hooks.json
│       ├── secrets.json
│       ├── config.json
│       └── variables.json
├── requests
│   └── httpbin.md
└── scripts
    └── test.lua

Request files

This is how a request file looks like

POST httpbin.org/post
Content-Type: application/json

{
  "name": "${Env.name}"
}

---
# Request documentation

Here is some valid markdown

Now, there is a lot to unpack here.

The first two lines are self explanatory. Any line that comes directly after the request is treated like a header, so it has to follow this key:value syntax

After the blank like, we have our body. There is nothing special about the request body, it is just sent as raw text. The tool doesn't detect when you are sending json, so you are supposed to add the Content-Type header by yourself.

After the body, we can see a triple dash separating the request from the document. This second section is just raw text that you can use to add informations about your request. This second part is optional, so you can omit the triple dash and not include it at all.

Also, we do have this interpolated value (${Env.name}), this is an env variable

These request files can be organized however you want, as long as they are inside of the requests/ folder, you will be able to call them from their unique path.

Env files

Env variable files are just json files with values. Any json valid value is accepted, even objects. You are not supposed to throw secrets into environments, we will get there yet.

{
  "name": "John"
}

Same goes for secrets.

This is what a hooks file looks like

{
  "pre-request": {
    "enabled": true,
    "scripts": ["pre.lua"]
  },
  "post-request": {
    "enabled": false,
    "scripts": ["post.lua"]
  }
}

The keys are the event names. The scripts path is relative to the scripts folder, and the scripts are executed in the order they are passed to the array.

Scripts

Scripts are just lua scripts. We will have more details about its API later.

Secrets

Secrets are just like env variables, but they are not supposed to be tracked by VCS

{
  "password": "shhhh"
}

Commands

Init

Initializes Lapse space at current dir, setting up some files and directories as well.

lapse init

Ls

Lists all requests.

lapse ls

Send

Sends a request. The query argument will be used to fuzzy search for the request. Should the search match more than one request, the user will be prompted a selector, which is also the behavior for when the query argument is omited.

lapse send [query]

The way it searches, it uses the request path as a string to query. So if we have something like:

├── .lapse
├── env
│   └── default.json
├── requests
│   ├── httpbin.md
│   └── httpbin
│       └── get.md

The searchable entries would be:

"httpbin"
"httpbin/get"

So, a query like "hg" would match the second entry.

Run

Runs a script. 91E0

lapse run [query]

You can also use script run:

lapse script run [query]

Script list

Lists all scripts.

lapse script ls

Completion

Outputs the completion script to a given shell.

lapse completion <shell>

Env ls

Lists all environments.

lapse env ls

Env switch

Switches to an enviromnent.

lapse env switch [query]

Log

Lists the latest requests. If a index is given, it lists detailed info about the log

lapse log [index]

Evaluation API

Env table

If your env looks like this:

{
  "name": "John"
}

You can access values like this:

POST https://names.com/${Env.name}

Secrets table

If your secrets.json file looks like this

{
  "password": "Shhhh"
}

You can access values like this:

POST https://auth.com/${Secret.password}

Scripts API

Request

Sends a request, and returns a table that represents a response log.

local req = Lapse:get_request("httpbin/get")
local result = Lapse:request(req)
print(result.status)
print(result.text)
print(result.duration)

for k, v in pairs(result.headers) do
  print(k, v)
end

License

This project is licensed under the GNU General Public License version 3 or later (GPL-3.0-or-later).

See LICENSE for the full license text.

About

HTTP CLI focused on UX and git-heavy workflows

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Contributors

Languages

0