Skip to content

Commit 51bf5bf

Browse files
committed
Add Zapfile examples
1 parent 3a6e283 commit 51bf5bf

File tree

15 files changed

+90
-5
lines changed

15 files changed

+90
-5
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
permissions: write-all
1717
strategy:
1818
matrix:
19-
python-version: [ "3.13.0" ]
19+
python-version: [ "3.10.16" ]
2020
name: Python ${{ matrix.python-version }}
2121
env:
2222
TAG: devcontainer-${{ matrix.python-version }}-${{ github.head_ref || github.ref_name }}

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,23 @@
44

55
An API Client for the terminal. A Python CLI for API testing and development.
66

7+
```bash
8+
usage: zap [-h] {run,curl,cookies,vars,version} ...
9+
10+
An API Client for the terminal. A Python CLI for API testing and development.
11+
12+
options:
13+
-h, --help show this help message and exit
14+
15+
commands:
16+
{run,curl,cookies,vars,version}
17+
run 🚀 run a Zapfile
18+
curl 🌊 print the curl command for a Zapfile
19+
cookies 🍪 view stored cookies
20+
vars 📋 view stored variables
21+
version 🔖 show version
22+
```
23+
724
## ✨ Features
825

926
- 🛠️ Environments & variables

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry] # https://python-poetry.org/docs/pyproject/
22
name = "zapman"
3-
version = "0.0.1"
3+
version = "0.0.2"
44
description = "An API Client for the terminal. A Python CLI for API testing and development."
55
authors = []
66
license = "Proprietary"

src/zapman/__main__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ def main() -> None: # noqa: PLR0911,C901
1919

2020
parser = argparse.ArgumentParser(
2121
prog="zap",
22-
description="A Python tool for API testing and development in your terminal.",
22+
description="An API Client for the terminal. A Python CLI for API testing and development.",
2323
)
24+
2425
subparser = parser.add_subparsers(
2526
title="commands",
2627
dest="command",
@@ -34,9 +35,8 @@ def main() -> None: # noqa: PLR0911,C901
3435
run.add_argument("-d", "--download", action="store_true", help="💾 download the response body")
3536
run.add_argument("-q", "--quiet", action="store_true", help="🤫 suppress output")
3637
run.add_argument("-v", "--verbose", action="store_true", help="🐞 enable debug logging", default=False)
37-
run.add_argument("--curl", action="store_true", help="🌊 print the curl command")
3838
run.add_argument("path", type=str, help="🐍 the Zapfile to execute", nargs="?", default=None)
39-
curl = subparser.add_parser("curl", help="🌊 print curl command")
39+
curl = subparser.add_parser("curl", help="🌊 print the curl command for a Zapfile")
4040
curl.add_argument("-e", "--env", type=str, help="🌐 API environment to use (default=default)", default="default")
4141
curl.add_argument("path", type=str, help="🐍 the Zapfile to print the curl command")
4242
subparser.add_parser("cookies", help="🍪 view stored cookies")

zaps/cookies.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
###################################
2+
# $ zap run cookies.py
3+
# $ zap cookies
4+
###################################
5+
6+
GET = "https://pie.dev/cookies/set/foo/bar"

zaps/delete.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
###################################
2+
# $ zap run delete.py
3+
###################################
14
from zapman import env
25

36
DELETE = f"{env['endpoint']}/delete"

zaps/download.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
###################################
2+
# $ zap run download.py
3+
###################################
4+
from zapman import After
5+
6+
GET = "https://httpbin.org/get"
7+
8+
DOWNLOAD = True
9+
10+
11+
def after(ctx: After) -> None:
12+
ctx.info("Downloaded 🤘")
13+
if ctx.output_file:
14+
print(ctx.output_file.read_text())

zaps/empty.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
###################################
2+
# $ zap run empty.py
3+
###################################

zaps/error.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
###################################
2+
# $ zap run error.py
3+
###################################
4+
GET = 1
5+
BODY_JSON = ""

zaps/form.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
###################################
2+
# $ zap run form.py
3+
###################################
14
from zapman import env
25

36
POST = f"{env['endpoint']}/post"

0 commit comments

Comments
 (0)