mirror of
https://github.com/aykhans/sarin.git
synced 2026-10-16 06:33:53 +00:00
Compare commits
67
Commits
v1.4.0
..
3d535d89e3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d535d89e3 | ||
|
|
3a23b1b370 | ||
|
|
a37885a308 | ||
|
|
9de1d5ac93 | ||
|
|
6fc17d1e10 | ||
|
|
4518895ab2 | ||
|
|
8b6e88bb74 | ||
|
|
163de9ffc9
|
||
|
|
969337f4ec
|
||
|
|
ce6b60520f
|
||
|
|
ae34ae037a
|
||
|
|
27c00581a9 | ||
|
|
db9a65f35f
|
||
|
|
082851d25e
|
||
|
|
62afa38370 | ||
|
|
373bc39f8e | ||
|
|
2b7c08519e | ||
|
|
f974b5d708 | ||
|
|
74ac84eb31 | ||
|
|
9cd3ec0539 | ||
|
|
42de488430 | ||
|
|
6e984f039c
|
||
|
|
73285b66b5 | ||
|
|
f003bd1061
|
||
|
|
07b2bb706e
|
||
|
|
67db8ac0e6
|
||
|
|
d99c76d175
|
||
|
|
623c1c4d97 | ||
|
|
f5eaf76fc4 | ||
|
|
7ec63a2a43 | ||
|
|
492c3f1449 | ||
|
|
d03d34576e
|
||
|
|
8beff615bb | ||
|
|
a85c82e751
|
||
|
|
ad5cfadaf2 | ||
|
|
8078b2c1fe | ||
|
|
3c4f449c97
|
||
|
|
deba048e3c | ||
|
|
77e8bc1eb8 | ||
|
|
a81d95ef6d
|
||
|
|
8195b92547 | ||
|
|
f42c4c70bf | ||
|
|
f3f25e3ba1
|
||
|
|
8121d75a2c
|
||
|
|
3867140704 | ||
|
|
740b6f6bbb
|
||
|
|
88180ae288
|
||
|
|
0314ea4f3e
|
||
|
|
9602595216
|
||
|
|
c195ca2ab2
|
||
|
|
e13eb9b8a8
|
||
|
|
d68c557dd3
|
||
|
|
d08b6dc222
|
||
|
|
8552aab3b1
|
||
|
|
79143beec9 | ||
|
|
bb1ed1c2ce | ||
|
|
a3434b096a | ||
|
|
e83e9346a3
|
||
|
|
01b5233167
|
||
|
|
e93b729145 | ||
|
|
372d228bb1
|
||
|
|
52a6e78e0c | ||
|
|
b22e3a0d25
|
||
|
|
4b52556b30
|
||
|
|
755545d838
|
||
|
|
dc2cd6cf63 | ||
|
|
838d65d83f |
No files matched your search
@@ -16,7 +16,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v7
|
- uses: actions/checkout@v7
|
||||||
- uses: actions/setup-go@v7
|
- uses: actions/setup-go@v7
|
||||||
with:
|
with:
|
||||||
go-version: 1.26.5
|
go-version-file: go.mod
|
||||||
- name: go fix
|
- name: go fix
|
||||||
run: |
|
run: |
|
||||||
go fix ./...
|
go fix ./...
|
||||||
@@ -24,4 +24,4 @@ jobs:
|
|||||||
- name: golangci-lint
|
- name: golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v9
|
uses: golangci/golangci-lint-action@v9
|
||||||
with:
|
with:
|
||||||
version: v2.12.2
|
version: v2.13.2
|
||||||
@@ -0,0 +1,172 @@
|
|||||||
|
name: nix
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- "go.mod"
|
||||||
|
- "go.sum"
|
||||||
|
- "nix/**"
|
||||||
|
- "flake.nix"
|
||||||
|
- "flake.lock"
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
ref:
|
||||||
|
description: "Ref to check out. Defaults to the triggering ref."
|
||||||
|
type: string
|
||||||
|
required: false
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: nix-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}
|
||||||
|
# Keyed on the PR author, which is stable across the fix-up push, so the run
|
||||||
|
# started by that push cannot cancel the run that made it.
|
||||||
|
cancel-in-progress: ${{ github.event_name == 'pull_request' && github.event.pull_request.user.login != 'dependabot[bot]' }}
|
||||||
|
|
||||||
|
env:
|
||||||
|
SELF_HOSTED_PR: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository }}
|
||||||
|
IS_DEPENDABOT: ${{ github.actor == 'dependabot[bot]' }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
# The only write is git push, which authenticates with the PAT that
|
||||||
|
# checkout persists, not with GITHUB_TOKEN.
|
||||||
|
contents: read
|
||||||
|
pull-requests: write
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v7
|
||||||
|
with:
|
||||||
|
# head.sha, not the merge ref: the hash is computed for the tree that
|
||||||
|
# gets pushed, and the run that verifies it must build that same tree.
|
||||||
|
ref: ${{ inputs.ref || github.event.pull_request.head.sha || github.ref }}
|
||||||
|
token: ${{ (env.IS_DEPENDABOT == 'true' && secrets.DEPENDABOT) || secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- uses: cachix/install-nix-action@v31
|
||||||
|
with:
|
||||||
|
github_access_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: nix build
|
||||||
|
id: build
|
||||||
|
continue-on-error: ${{ env.SELF_HOSTED_PR == 'true' }}
|
||||||
|
run: nix build .#default --no-link --print-build-logs
|
||||||
|
|
||||||
|
- name: Recompute vendorHash
|
||||||
|
id: hash
|
||||||
|
if: steps.build.outcome == 'failure' && env.SELF_HOSTED_PR == 'true'
|
||||||
|
run: |
|
||||||
|
nix run nixpkgs#nix-update -- --flake --version=skip --no-src default
|
||||||
|
|
||||||
|
# An unchanged hash means the build broke for some other reason. Say
|
||||||
|
# nothing and let the job fail on the real error.
|
||||||
|
if git diff --quiet -- nix/package.nix; then
|
||||||
|
echo "stale=false" >> "$GITHUB_OUTPUT"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "stale=true" >> "$GITHUB_OUTPUT"
|
||||||
|
sed -n 's/^[[:space:]]*vendorHash = "\([^"]*\)".*/hash=\1/p' nix/package.nix >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Push vendorHash fix
|
||||||
|
if: steps.hash.outputs.stale == 'true' && env.IS_DEPENDABOT == 'true'
|
||||||
|
env:
|
||||||
|
HEAD_REF: ${{ github.head_ref }}
|
||||||
|
PUSH_TOKEN: ${{ secrets.DEPENDABOT }}
|
||||||
|
run: |
|
||||||
|
if [ -z "$PUSH_TOKEN" ]; then
|
||||||
|
echo "::error::the DEPENDABOT push token is missing from the Dependabot secret store"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
git config user.name "github-actions[bot]"
|
||||||
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||||
|
git add nix/package.nix
|
||||||
|
git commit -m "fix(nix): update vendorHash [dependabot skip]"
|
||||||
|
git push origin "HEAD:refs/heads/$HEAD_REF"
|
||||||
|
echo "::notice::vendorHash updated and pushed; the run on the new commit decides this PR"
|
||||||
|
|
||||||
|
- name: Comment stale vendorHash
|
||||||
|
if: steps.hash.outputs.stale == 'true' && env.IS_DEPENDABOT != 'true'
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
PR: ${{ github.event.pull_request.number }}
|
||||||
|
HASH: ${{ steps.hash.outputs.hash }}
|
||||||
|
run: |
|
||||||
|
marker='<!-- vendorhash-bot -->'
|
||||||
|
body=$(cat <<EOF
|
||||||
|
$marker
|
||||||
|
### \`nix/package.nix\` vendorHash is stale
|
||||||
|
|
||||||
|
This branch changes the Go dependencies, so the vendor derivation no longer matches the pinned hash and \`nix build\` fails.
|
||||||
|
|
||||||
|
\`\`\`nix
|
||||||
|
vendorHash = "$HASH";
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
Run \`task nix-hash\` locally and commit the result, or paste the hash above.
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
|
||||||
|
# Keep one sticky comment instead of a new one on every push. Without
|
||||||
|
# the explicit check a failed lookup reads as "no comment yet" and
|
||||||
|
# posts a duplicate; piping into head would hide the exit status.
|
||||||
|
if ! matches=$(gh api --paginate "repos/$GITHUB_REPOSITORY/issues/$PR/comments?per_page=100" \
|
||||||
|
--jq ".[] | select(.user.login == \"github-actions[bot]\" and ((.body // \"\") | contains(\"$marker\"))) | .id"); then
|
||||||
|
echo "::error::could not list the pull request comments"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
id=$(printf '%s\n' "$matches" | head -n 1)
|
||||||
|
if [ -n "$id" ]; then
|
||||||
|
gh api -X PATCH "repos/$GITHUB_REPOSITORY/issues/comments/$id" -f body="$body" >/dev/null
|
||||||
|
else
|
||||||
|
gh pr comment "$PR" --body "$body"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Once the hash is fixed the build passes and the step above stops running,
|
||||||
|
# so without this the comment keeps claiming the branch is broken under a
|
||||||
|
# green check.
|
||||||
|
- name: Resolve stale vendorHash comment
|
||||||
|
# Gated on the hash rather than the build: a later push can fix the hash
|
||||||
|
# while the build still fails for an unrelated reason, and the comment
|
||||||
|
# must stop blaming the vendor derivation either way. Skipped when the
|
||||||
|
# recompute itself errored, since then we do not know.
|
||||||
|
if: ${{ !cancelled() && env.SELF_HOSTED_PR == 'true' && steps.hash.outputs.stale != 'true' && steps.hash.outcome != 'failure' }}
|
||||||
|
continue-on-error: true
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
PR: ${{ github.event.pull_request.number }}
|
||||||
|
BUILD: ${{ steps.build.outcome }}
|
||||||
|
run: |
|
||||||
|
marker='<!-- vendorhash-bot -->'
|
||||||
|
if ! matches=$(gh api --paginate "repos/$GITHUB_REPOSITORY/issues/$PR/comments?per_page=100" \
|
||||||
|
--jq ".[] | select(.user.login == \"github-actions[bot]\" and ((.body // \"\") | contains(\"$marker\"))) | .id"); then
|
||||||
|
echo "::error::could not list the pull request comments"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
id=$(printf '%s\n' "$matches" | head -n 1)
|
||||||
|
[ -n "$id" ] || exit 0
|
||||||
|
|
||||||
|
if [ "$BUILD" = "success" ]; then
|
||||||
|
detail='`nix build` passes on this branch.'
|
||||||
|
else
|
||||||
|
detail='The build is failing for another reason; see the workflow log.'
|
||||||
|
fi
|
||||||
|
body=$(cat <<EOF
|
||||||
|
$marker
|
||||||
|
### \`nix/package.nix\` vendorHash is up to date
|
||||||
|
|
||||||
|
$detail
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
gh api -X PATCH "repos/$GITHUB_REPOSITORY/issues/comments/$id" -f body="$body" >/dev/null
|
||||||
|
|
||||||
|
- name: Report build failure
|
||||||
|
if: ${{ !cancelled() && steps.build.outcome == 'failure' && !(env.IS_DEPENDABOT == 'true' && steps.hash.outputs.stale == 'true') }}
|
||||||
|
run: |
|
||||||
|
echo "::error file=nix/package.nix::nix build failed; see the log above"
|
||||||
|
exit 1
|
||||||
+122
-26
@@ -2,50 +2,101 @@ name: Build and Release
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
release:
|
release:
|
||||||
types: [created]
|
types: [published]
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
tag:
|
|
||||||
description: "Release tag (e.g., v1.0.0)"
|
|
||||||
required: true
|
|
||||||
build_binaries:
|
|
||||||
description: "Build and upload binaries"
|
|
||||||
type: boolean
|
|
||||||
default: true
|
|
||||||
build_docker:
|
|
||||||
description: "Build and push Docker image"
|
|
||||||
type: boolean
|
|
||||||
default: true
|
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
nix:
|
||||||
|
name: Verify Nix package
|
||||||
|
uses: ./.github/workflows/nix.yaml
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
pull-requests: write
|
||||||
|
with:
|
||||||
|
ref: ${{ github.ref }}
|
||||||
|
|
||||||
|
# Gate: the tag must come from main, agree with the pre-release flag, and match
|
||||||
|
# the hand-bumped version in nix/package.nix.
|
||||||
|
version:
|
||||||
|
name: Verify release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
env:
|
||||||
|
TAG: ${{ github.ref_name }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v7
|
||||||
|
with:
|
||||||
|
ref: ${{ github.ref }}
|
||||||
|
# Full history so the tag can be located on main's first-parent line.
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Check the tag is on main
|
||||||
|
run: |
|
||||||
|
git fetch --no-tags origin "+refs/heads/main:refs/remotes/origin/main"
|
||||||
|
git rev-list --first-parent refs/remotes/origin/main > "$RUNNER_TEMP/first-parent.txt"
|
||||||
|
if ! grep -qxF "$GITHUB_SHA" "$RUNNER_TEMP/first-parent.txt"; then
|
||||||
|
echo "::error::$TAG ($GITHUB_SHA) is not on main; releases must be cut from main"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Check the tag matches the pre-release flag
|
||||||
|
env:
|
||||||
|
PRERELEASE: ${{ github.event.release.prerelease }}
|
||||||
|
run: |
|
||||||
|
# The flag comes from the checkbox, not the tag name, so without this a
|
||||||
|
# tag like v1.5.0-rc1 published as stable would move :latest.
|
||||||
|
case "$TAG" in
|
||||||
|
*-*)
|
||||||
|
if [ "$PRERELEASE" != "true" ]; then
|
||||||
|
echo "::error::tag '$TAG' carries a pre-release suffix but the release is not marked as a pre-release"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
- name: Check nix/package.nix matches the release tag
|
||||||
|
run: |
|
||||||
|
expected="${TAG#v}"
|
||||||
|
expected="${expected%%-*}"
|
||||||
|
actual="$(sed -n 's/^[[:space:]]*version = "\([^"]*\)".*/\1/p' nix/package.nix | head -1)"
|
||||||
|
if [ -z "$actual" ]; then
|
||||||
|
echo "::error file=nix/package.nix::could not read the version string"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ "$actual" != "$expected" ]; then
|
||||||
|
echo "::error file=nix/package.nix::version is '$actual' but the release tag is '$TAG' (expected '$expected')"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "nix/package.nix version '$actual' matches tag '$TAG'"
|
||||||
|
|
||||||
build:
|
build:
|
||||||
name: Build binaries
|
name: Build binaries
|
||||||
|
needs: [nix, version]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v7
|
uses: actions/checkout@v7
|
||||||
with:
|
with:
|
||||||
ref: ${{ inputs.tag || github.ref }}
|
ref: ${{ github.ref }}
|
||||||
|
|
||||||
- name: Set build metadata
|
- name: Set build metadata
|
||||||
run: |
|
run: |
|
||||||
echo "VERSION=$(git describe --tags --always)" >> $GITHUB_ENV
|
echo "VERSION=$(git describe --tags --always)" >> $GITHUB_ENV
|
||||||
echo "GIT_COMMIT=$(git rev-parse HEAD)" >> $GITHUB_ENV
|
echo "GIT_COMMIT=$(git rev-parse HEAD)" >> $GITHUB_ENV
|
||||||
echo "GO_VERSION=1.26.5" >> $GITHUB_ENV
|
echo "GO_VERSION=$(sed -n 's/^go //p' go.mod)" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
if: github.event_name == 'release' || inputs.build_binaries
|
|
||||||
uses: actions/setup-go@v7
|
uses: actions/setup-go@v7
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version-file: go.mod
|
||||||
cache: true
|
cache: true
|
||||||
|
|
||||||
- name: Build binaries
|
- name: Build binaries
|
||||||
if: github.event_name == 'release' || inputs.build_binaries
|
|
||||||
run: |
|
run: |
|
||||||
LDFLAGS="-X 'go.aykhans.me/sarin/internal/version.Version=${{ env.VERSION }}' \
|
LDFLAGS="-X 'go.aykhans.me/sarin/internal/version.Version=${{ env.VERSION }}' \
|
||||||
-X 'go.aykhans.me/sarin/internal/version.GitCommit=${{ env.GIT_COMMIT }}' \
|
-X 'go.aykhans.me/sarin/internal/version.GitCommit=${{ env.GIT_COMMIT }}' \
|
||||||
@@ -63,29 +114,24 @@ jobs:
|
|||||||
CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build -ldflags "$LDFLAGS" -o ./sarin-windows-arm64.exe ./cmd/cli/main.go
|
CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build -ldflags "$LDFLAGS" -o ./sarin-windows-arm64.exe ./cmd/cli/main.go
|
||||||
|
|
||||||
- name: Upload Release Assets
|
- name: Upload Release Assets
|
||||||
if: github.event_name == 'release' || inputs.build_binaries
|
|
||||||
uses: softprops/action-gh-release@v3
|
uses: softprops/action-gh-release@v3
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ inputs.tag || github.ref_name }}
|
tag_name: ${{ github.ref_name }}
|
||||||
files: ./sarin-*
|
files: ./sarin-*
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
if: github.event_name == 'release' || inputs.build_docker
|
|
||||||
uses: docker/setup-qemu-action@v4
|
uses: docker/setup-qemu-action@v4
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
if: github.event_name == 'release' || inputs.build_docker
|
|
||||||
uses: docker/setup-buildx-action@v4
|
uses: docker/setup-buildx-action@v4
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
if: github.event_name == 'release' || inputs.build_docker
|
|
||||||
uses: docker/login-action@v4
|
uses: docker/login-action@v4
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
if: github.event_name == 'release' || inputs.build_docker
|
|
||||||
uses: docker/build-push-action@v7
|
uses: docker/build-push-action@v7
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
@@ -95,6 +141,56 @@ jobs:
|
|||||||
VERSION=${{ env.VERSION }}
|
VERSION=${{ env.VERSION }}
|
||||||
GIT_COMMIT=${{ env.GIT_COMMIT }}
|
GIT_COMMIT=${{ env.GIT_COMMIT }}
|
||||||
GO_VERSION=${{ env.GO_VERSION }}
|
GO_VERSION=${{ env.GO_VERSION }}
|
||||||
|
# A pre-release must not take over the tag people get by default.
|
||||||
tags: |
|
tags: |
|
||||||
${{ secrets.DOCKERHUB_USERNAME }}/sarin:${{ env.VERSION }}
|
${{ secrets.DOCKERHUB_USERNAME }}/sarin:${{ env.VERSION }}
|
||||||
${{ secrets.DOCKERHUB_USERNAME }}/sarin:latest
|
${{ !github.event.release.prerelease && format('{0}/sarin:latest', secrets.DOCKERHUB_USERNAME) || '' }}
|
||||||
|
|
||||||
|
# Moving pointer at the newest stable release, so flake users can follow
|
||||||
|
# releases instead of main. Fast-forward only.
|
||||||
|
release-branch:
|
||||||
|
name: Advance release branch
|
||||||
|
needs: build
|
||||||
|
if: ${{ !github.event.release.prerelease }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
# Serialize: concurrent releases would otherwise race the push.
|
||||||
|
concurrency:
|
||||||
|
group: release-branch
|
||||||
|
cancel-in-progress: false
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v7
|
||||||
|
with:
|
||||||
|
# The checks below compare against $GITHUB_SHA; check out exactly that.
|
||||||
|
ref: ${{ github.sha }}
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Point release at the tag
|
||||||
|
env:
|
||||||
|
TAG: ${{ github.ref_name }}
|
||||||
|
run: |
|
||||||
|
# Refresh: checkout fetched this, but as of a few seconds ago.
|
||||||
|
git fetch --no-tags origin "+refs/heads/release:refs/remotes/origin/release" || true
|
||||||
|
|
||||||
|
if git rev-parse --verify --quiet refs/remotes/origin/release >/dev/null; then
|
||||||
|
# At or behind the pointer: a re-run of this or an older release.
|
||||||
|
if git merge-base --is-ancestor "$GITHUB_SHA" refs/remotes/origin/release; then
|
||||||
|
if [ "$(git rev-parse refs/remotes/origin/release)" = "$GITHUB_SHA" ]; then
|
||||||
|
echo "::notice::release is already at $TAG"
|
||||||
|
else
|
||||||
|
echo "::warning::release is ahead of $TAG; leaving it alone"
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
# The version job put this commit on main, so a pointer that is neither
|
||||||
|
# behind nor ahead is off main history and can never fast-forward again.
|
||||||
|
if ! git merge-base --is-ancestor refs/remotes/origin/release "$GITHUB_SHA"; then
|
||||||
|
echo "::error::release ($(git rev-parse --short refs/remotes/origin/release)) has diverged from main and can no longer fast-forward to $TAG; reset it by hand"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
git push origin "$GITHUB_SHA:refs/heads/release"
|
||||||
|
echo "::notice::release branch now points at $TAG"
|
||||||
+6
-1
@@ -1,7 +1,7 @@
|
|||||||
version: "2"
|
version: "2"
|
||||||
|
|
||||||
run:
|
run:
|
||||||
go: "1.26"
|
go: "1.27"
|
||||||
concurrency: 12
|
concurrency: 12
|
||||||
|
|
||||||
linters:
|
linters:
|
||||||
@@ -81,6 +81,11 @@ linters:
|
|||||||
- staticcheck
|
- staticcheck
|
||||||
text: "SA5011"
|
text: "SA5011"
|
||||||
|
|
||||||
|
- linters:
|
||||||
|
- errcheck
|
||||||
|
- gosec
|
||||||
|
source: "lipgloss\\.Println\\("
|
||||||
|
|
||||||
formatters:
|
formatters:
|
||||||
enable:
|
enable:
|
||||||
- gofmt
|
- gofmt
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
ARG GO_VERSION=1.26.5
|
ARG GO_VERSION=1.27.1
|
||||||
|
|
||||||
FROM docker.io/library/golang:${GO_VERSION}-alpine AS builder
|
FROM docker.io/library/golang:${GO_VERSION}-alpine AS builder
|
||||||
|
|
||||||
|
|||||||
@@ -26,13 +26,11 @@ Sarin is designed for efficient HTTP load testing with minimal resource consumpt
|
|||||||
|
|
||||||
| ✅ Supported | ❌ Not Supported |
|
| ✅ Supported | ❌ Not Supported |
|
||||||
| ---------------------------------------------------------- | ------------------------------- |
|
| ---------------------------------------------------------- | ------------------------------- |
|
||||||
| High-performance with low memory footprint | Detailed response body analysis |
|
| High-performance with low memory footprint | Web UI or complex TUI |
|
||||||
| Long-running duration/count based tests | Extensive response statistics |
|
| Dynamic requests via 370+ template functions | Detailed response body analysis |
|
||||||
| Dynamic requests via 340+ template functions | Web UI or complex TUI |
|
|
||||||
| Request scripting with Lua and JavaScript | Distributed load testing |
|
| Request scripting with Lua and JavaScript | Distributed load testing |
|
||||||
| Multiple proxy protocols<br>(HTTP, HTTPS, SOCKS5, SOCKS5H) | HTTP/2, HTTP/3, WebSocket, gRPC |
|
| Multiple proxy protocols<br>(HTTP, HTTPS, SOCKS5, SOCKS5H) | HTTP/2, HTTP/3, WebSocket, gRPC |
|
||||||
| Captcha solving<br>(2Captcha, Anti-Captcha, CapSolver) | Plugins / extensions ecosystem |
|
| Captcha solving<br>(2Captcha, Anti-Captcha, CapSolver) | Plugins / extensions ecosystem |
|
||||||
| Flexible config (CLI, ENV, YAML) | |
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@@ -40,7 +38,7 @@ Sarin is designed for efficient HTTP load testing with minimal resource consumpt
|
|||||||
<summary><b>Docker</b></summary>
|
<summary><b>Docker</b></summary>
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
docker run -it aykhans/sarin:latest --version
|
docker run --rm -it aykhans/sarin:latest --version
|
||||||
```
|
```
|
||||||
|
|
||||||
With a local config file:
|
With a local config file:
|
||||||
@@ -63,20 +61,20 @@ docker run --rm -it aykhans/sarin -f https://example.com/config.yaml
|
|||||||
Run directly without installing (requires flakes enabled):
|
Run directly without installing (requires flakes enabled):
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
nix run github:aykhans/sarin -- -U http://example.com -r 100 -c 10
|
nix run github:aykhans/sarin/release -- -U http://example.com -r 100 -c 10
|
||||||
```
|
```
|
||||||
|
|
||||||
Install into your profile:
|
Install into your profile:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
nix profile install github:aykhans/sarin
|
nix profile install github:aykhans/sarin/release
|
||||||
```
|
```
|
||||||
|
|
||||||
Or add it to your own flake via the overlay:
|
Or add it to your own flake via the overlay:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
inputs.sarin.url = "github:aykhans/sarin";
|
inputs.sarin.url = "github:aykhans/sarin/release";
|
||||||
|
|
||||||
# In your outputs, apply the overlay to nixpkgs:
|
# In your outputs, apply the overlay to nixpkgs:
|
||||||
# nixpkgs.overlays = [ inputs.sarin.overlays.default ];
|
# nixpkgs.overlays = [ inputs.sarin.overlays.default ];
|
||||||
@@ -84,6 +82,8 @@ Or add it to your own flake via the overlay:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The `release` branch tracks the newest stable release cut from `main`, so `nix flake update` moves between releases rather than following every commit; pre-releases are excluded. Pin an exact release with `github:aykhans/sarin/v1.4.2`, or track development with `github:aykhans/sarin` (the `main` branch).
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
@@ -96,7 +96,7 @@ Download the latest binaries from the [releases](https://github.com/aykhans/sari
|
|||||||
<details>
|
<details>
|
||||||
<summary><b>Building from Source</b></summary>
|
<summary><b>Building from Source</b></summary>
|
||||||
|
|
||||||
Requires [Go 1.26+](https://golang.org/dl/).
|
Requires the [Go version declared in `go.mod`](go.mod).
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
git clone https://github.com/aykhans/sarin.git && cd sarin
|
git clone https://github.com/aykhans/sarin.git && cd sarin
|
||||||
@@ -146,7 +146,7 @@ For detailed documentation on all configuration options (URL, method, timeout, c
|
|||||||
|
|
||||||
## Templating
|
## Templating
|
||||||
|
|
||||||
Sarin supports Go templates in URL paths, methods, bodies, headers, params, cookies, and values. Use the 340+ built-in functions to generate dynamic data for each request.
|
Sarin supports Go templates in URL paths, methods, bodies, headers, params, cookies, and values. Use the 370+ built-in functions to generate dynamic data for each request.
|
||||||
|
|
||||||
**Example:**
|
**Example:**
|
||||||
|
|
||||||
|
|||||||
+9
-3
@@ -3,7 +3,9 @@ version: "3"
|
|||||||
|
|
||||||
vars:
|
vars:
|
||||||
BIN_DIR: ./bin
|
BIN_DIR: ./bin
|
||||||
GOLANGCI_LINT_VERSION: v2.12.2
|
GO_VERSION:
|
||||||
|
sh: sed -n 's/^go //p' go.mod
|
||||||
|
GOLANGCI_LINT_VERSION: v2.13.2
|
||||||
GOLANGCI: "{{.BIN_DIR}}/golangci-lint-{{.GOLANGCI_LINT_VERSION}}"
|
GOLANGCI: "{{.BIN_DIR}}/golangci-lint-{{.GOLANGCI_LINT_VERSION}}"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
@@ -39,6 +41,11 @@ tasks:
|
|||||||
cmds:
|
cmds:
|
||||||
- "{{.GOLANGCI}} run"
|
- "{{.GOLANGCI}} run"
|
||||||
|
|
||||||
|
nix-hash:
|
||||||
|
desc: Recompute nix/package.nix vendorHash after a dependency change.
|
||||||
|
cmds:
|
||||||
|
- nix run nixpkgs#nix-update -- --flake --version=skip --no-src default
|
||||||
|
|
||||||
test:
|
test:
|
||||||
desc: Run Go tests.
|
desc: Run Go tests.
|
||||||
cmds:
|
cmds:
|
||||||
@@ -82,7 +89,6 @@ tasks:
|
|||||||
vars:
|
vars:
|
||||||
IMAGE_NAME: '{{.IMAGE_NAME | default "sarin"}}'
|
IMAGE_NAME: '{{.IMAGE_NAME | default "sarin"}}'
|
||||||
TAG: '{{.TAG | default "latest"}}'
|
TAG: '{{.TAG | default "latest"}}'
|
||||||
GO_VERSION: '{{.GO_VERSION | default ""}}'
|
|
||||||
VERSION:
|
VERSION:
|
||||||
sh: git describe --tags --always
|
sh: git describe --tags --always
|
||||||
GIT_COMMIT:
|
GIT_COMMIT:
|
||||||
@@ -90,7 +96,7 @@ tasks:
|
|||||||
cmds:
|
cmds:
|
||||||
- >-
|
- >-
|
||||||
docker build
|
docker build
|
||||||
{{if .GO_VERSION}}--build-arg GO_VERSION={{.GO_VERSION}}{{end}}
|
--build-arg GO_VERSION={{.GO_VERSION}}
|
||||||
--build-arg VERSION={{.VERSION}}
|
--build-arg VERSION={{.VERSION}}
|
||||||
--build-arg GIT_COMMIT={{.GIT_COMMIT}}
|
--build-arg GIT_COMMIT={{.GIT_COMMIT}}
|
||||||
-t {{.IMAGE_NAME}}:{{.TAG}}
|
-t {{.IMAGE_NAME}}:{{.TAG}}
|
||||||
|
|||||||
+8
-7
@@ -7,6 +7,7 @@ import (
|
|||||||
"os/signal"
|
"os/signal"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
|
"charm.land/lipgloss/v2"
|
||||||
"go.aykhans.me/sarin/internal/config"
|
"go.aykhans.me/sarin/internal/config"
|
||||||
"go.aykhans.me/sarin/internal/sarin"
|
"go.aykhans.me/sarin/internal/sarin"
|
||||||
"go.aykhans.me/sarin/internal/types"
|
"go.aykhans.me/sarin/internal/types"
|
||||||
@@ -32,13 +33,13 @@ func main() {
|
|||||||
utilsErr.OnType(func(err types.FieldValidationErrors) error {
|
utilsErr.OnType(func(err types.FieldValidationErrors) error {
|
||||||
for _, fieldErr := range err.Errors {
|
for _, fieldErr := range err.Errors {
|
||||||
if fieldErr.Value == "" {
|
if fieldErr.Value == "" {
|
||||||
fmt.Fprintln(os.Stderr,
|
fmt.Fprint(os.Stderr, lipgloss.Sprintln(
|
||||||
config.StyleYellow.Render(fmt.Sprintf("[VALIDATION] Field '%s': ", fieldErr.Field))+fieldErr.Err.Error(),
|
config.StyleYellow.Render(fmt.Sprintf("[VALIDATION] Field '%s': ", fieldErr.Field))+fieldErr.Err.Error(),
|
||||||
)
|
))
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprintln(os.Stderr,
|
fmt.Fprint(os.Stderr, lipgloss.Sprintln(
|
||||||
config.StyleYellow.Render(fmt.Sprintf("[VALIDATION] Field '%s' (%s): ", fieldErr.Field, fieldErr.Value))+fieldErr.Err.Error(),
|
config.StyleYellow.Render(fmt.Sprintf("[VALIDATION] Field '%s' (%s): ", fieldErr.Field, fieldErr.Value))+fieldErr.Err.Error(),
|
||||||
)
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@@ -58,17 +59,17 @@ func main() {
|
|||||||
)
|
)
|
||||||
_ = utilsErr.MustHandle(err,
|
_ = utilsErr.MustHandle(err,
|
||||||
utilsErr.OnType(func(err types.ProxyDialError) error {
|
utilsErr.OnType(func(err types.ProxyDialError) error {
|
||||||
fmt.Fprintln(os.Stderr, config.StyleRed.Render("[PROXY] ")+err.Error())
|
fmt.Fprint(os.Stderr, lipgloss.Sprintln(config.StyleRed.Render("[PROXY] ")+err.Error()))
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
return nil
|
return nil
|
||||||
}),
|
}),
|
||||||
utilsErr.OnSentinel(types.ErrScriptEmpty, func(err error) error {
|
utilsErr.OnSentinel(types.ErrScriptEmpty, func(err error) error {
|
||||||
fmt.Fprintln(os.Stderr, config.StyleRed.Render("[SCRIPT] ")+err.Error())
|
fmt.Fprint(os.Stderr, lipgloss.Sprintln(config.StyleRed.Render("[SCRIPT] ")+err.Error()))
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
return nil
|
return nil
|
||||||
}),
|
}),
|
||||||
utilsErr.OnType(func(err types.ScriptLoadError) error {
|
utilsErr.OnType(func(err types.ScriptLoadError) error {
|
||||||
fmt.Fprintln(os.Stderr, config.StyleRed.Render("[SCRIPT] ")+err.Error())
|
fmt.Fprint(os.Stderr, lipgloss.Sprintln(config.StyleRed.Render("[SCRIPT] ")+err.Error()))
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
return nil
|
return nil
|
||||||
}),
|
}),
|
||||||
|
|||||||
+1
-1
@@ -373,7 +373,7 @@ body: '{"ip": "{{ fakeit_IPv4Address }}", "timestamp": "{{ fakeit_Date }}", "act
|
|||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
> For the complete list of 340+ template functions, see the **[Templating Guide](templating.md)**.
|
> For the complete list of 370+ template functions, see the **[Templating Guide](templating.md)**.
|
||||||
|
|
||||||
## Solving Captchas
|
## Solving Captchas
|
||||||
|
|
||||||
|
|||||||
+175
-139
@@ -249,7 +249,7 @@ The functions are organized by service: `twocaptcha_*`, `anticaptcha_*`, and `ca
|
|||||||
|
|
||||||
### 2Captcha
|
### 2Captcha
|
||||||
|
|
||||||
Functions for the [2Captcha](https://2captcha.com) service. Note: 2Captcha **does not currently support hCaptcha** through their API.
|
Functions for the [2Captcha](https://2captcha.com) service. Sarin supports reCAPTCHA v2, reCAPTCHA v3, and Cloudflare Turnstile through this integration.
|
||||||
|
|
||||||
| Function | Description |
|
| Function | Description |
|
||||||
| ------------------------------------------------------------------------ | ------------------------------------------------------------------------- |
|
| ------------------------------------------------------------------------ | ------------------------------------------------------------------------- |
|
||||||
@@ -259,7 +259,7 @@ Functions for the [2Captcha](https://2captcha.com) service. Note: 2Captcha **doe
|
|||||||
|
|
||||||
### Anti-Captcha
|
### Anti-Captcha
|
||||||
|
|
||||||
Functions for the [Anti-Captcha](https://anti-captcha.com) service. This is currently the only service that supports all four captcha types end-to-end.
|
Functions for the [Anti-Captcha](https://anti-captcha.com) service. This is the only Sarin captcha integration that exposes an hCaptcha function.
|
||||||
|
|
||||||
| Function | Description |
|
| Function | Description |
|
||||||
| ------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
|
| ------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
|
||||||
@@ -270,7 +270,7 @@ Functions for the [Anti-Captcha](https://anti-captcha.com) service. This is curr
|
|||||||
|
|
||||||
### CapSolver
|
### CapSolver
|
||||||
|
|
||||||
Functions for the [CapSolver](https://capsolver.com) service. Note: CapSolver no longer supports hCaptcha.
|
Functions for the [CapSolver](https://capsolver.com) service. Sarin supports reCAPTCHA v2, reCAPTCHA v3, and Cloudflare Turnstile through this integration.
|
||||||
|
|
||||||
| Function | Description |
|
| Function | Description |
|
||||||
| ----------------------------------------------------------------------- | ------------------------------------------------------------------------- |
|
| ----------------------------------------------------------------------- | ------------------------------------------------------------------------- |
|
||||||
@@ -302,7 +302,7 @@ body: |
|
|||||||
```
|
```
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# hCaptcha via Anti-Captcha (the only service that still supports it)
|
# hCaptcha via Anti-Captcha
|
||||||
method: POST
|
method: POST
|
||||||
url: https://example.com/protected
|
url: https://example.com/protected
|
||||||
body: |
|
body: |
|
||||||
@@ -325,10 +325,10 @@ These functions are powered by [gofakeit](https://github.com/brianvoe/gofakeit)
|
|||||||
|
|
||||||
### File
|
### File
|
||||||
|
|
||||||
| Function | Description | Example Output |
|
| Function | Description | Example Output |
|
||||||
| ---------------------- | -------------- | -------------------- |
|
| ---------------------- | -------------- | --------------------- |
|
||||||
| `fakeit_FileExtension` | File extension | `"nes"` |
|
| `fakeit_FileExtension` | File extension | `"nes"` |
|
||||||
| `fakeit_FileMimeType` | MIME type | `"application/json"` |
|
| `fakeit_FileMimeType` | MIME type | `"application/x-wri"` |
|
||||||
|
|
||||||
### ID
|
### ID
|
||||||
|
|
||||||
@@ -347,7 +347,7 @@ These functions are powered by [gofakeit](https://github.com/brianvoe/gofakeit)
|
|||||||
| `fakeit_ProductFeature` | Product feature | `"ultra-lightweight"` |
|
| `fakeit_ProductFeature` | Product feature | `"ultra-lightweight"` |
|
||||||
| `fakeit_ProductMaterial` | Product material | `"brass"` |
|
| `fakeit_ProductMaterial` | Product material | `"brass"` |
|
||||||
| `fakeit_ProductUPC` | UPC code | `"012780949980"` |
|
| `fakeit_ProductUPC` | UPC code | `"012780949980"` |
|
||||||
| `fakeit_ProductAudience` | Target audience | `["adults"]` |
|
| `fakeit_ProductAudience` | Target audience | `[adults]` |
|
||||||
| `fakeit_ProductDimension` | Product dimension | `"medium"` |
|
| `fakeit_ProductDimension` | Product dimension | `"medium"` |
|
||||||
| `fakeit_ProductUseCase` | Use case | `"home"` |
|
| `fakeit_ProductUseCase` | Use case | `"home"` |
|
||||||
| `fakeit_ProductBenefit` | Product benefit | `"comfort"` |
|
| `fakeit_ProductBenefit` | Product benefit | `"comfort"` |
|
||||||
@@ -356,23 +356,25 @@ These functions are powered by [gofakeit](https://github.com/brianvoe/gofakeit)
|
|||||||
|
|
||||||
### Person
|
### Person
|
||||||
|
|
||||||
| Function | Description | Example Output |
|
| Function | Description | Example Output |
|
||||||
| ----------------------- | ---------------------- | ------------------------ |
|
| ----------------------- | ---------------------- | ------------------------------------------------------------------- |
|
||||||
| `fakeit_Name` | Full name | `"Markus Moen"` |
|
| `fakeit_Name` | Full name | `"Priscilla Thornton"` |
|
||||||
| `fakeit_NamePrefix` | Name prefix | `"Mr."` |
|
| `fakeit_NamePrefix` | Name prefix | `"Mr."` |
|
||||||
| `fakeit_NameSuffix` | Name suffix | `"Jr."` |
|
| `fakeit_NameSuffix` | Name suffix | `"Jr."` |
|
||||||
| `fakeit_FirstName` | First name | `"Markus"` |
|
| `fakeit_FirstName` | First name | `"Priscilla"` |
|
||||||
| `fakeit_MiddleName` | Middle name | `"Belinda"` |
|
| `fakeit_MiddleName` | Middle name | `"Belinda"` |
|
||||||
| `fakeit_LastName` | Last name | `"Daniel"` |
|
| `fakeit_LastName` | Last name | `"Daniel"` |
|
||||||
| `fakeit_Gender` | Gender | `"male"` |
|
| `fakeit_Gender` | Gender | `"male"` |
|
||||||
| `fakeit_Age` | Age | `40` |
|
| `fakeit_Age` | Age | `40` |
|
||||||
| `fakeit_Ethnicity` | Ethnicity | `"German"` |
|
| `fakeit_Ethnicity` | Ethnicity | `"German"` |
|
||||||
| `fakeit_SSN` | Social Security Number | `"296446360"` |
|
| `fakeit_SSN` | Social Security Number | `"296446360"` |
|
||||||
| `fakeit_EIN` | Employer ID Number | `"12-3456789"` |
|
| `fakeit_EIN` | Employer ID Number | `"12-3456789"` |
|
||||||
| `fakeit_Hobby` | Hobby | `"Swimming"` |
|
| `fakeit_Hobby` | Hobby | `"Swimming"` |
|
||||||
| `fakeit_Email` | Email address | `"markusmoen@pagac.net"` |
|
| `fakeit_SocialMedia` | Social media profile | `"https://twitter.com/ImpossibleTrousers"` |
|
||||||
| `fakeit_Phone` | Phone number | `"6136459948"` |
|
| `fakeit_Bio` | Biography | `"Born in New York, John grew up to become a Software Engineer..."` |
|
||||||
| `fakeit_PhoneFormatted` | Formatted phone | `"136-459-9489"` |
|
| `fakeit_Email` | Email address | `"priscilla.thornton@duncan.biz"` |
|
||||||
|
| `fakeit_Phone` | Phone number | `"6136459948"` |
|
||||||
|
| `fakeit_PhoneFormatted` | Formatted phone | `"136-459-9489"` |
|
||||||
|
|
||||||
### Generate
|
### Generate
|
||||||
|
|
||||||
@@ -391,7 +393,7 @@ These functions are powered by [gofakeit](https://github.com/brianvoe/gofakeit)
|
|||||||
|
|
||||||
| Function | Description | Example Output |
|
| Function | Description | Example Output |
|
||||||
| --------------------------------------------------- | ---------------------------- | ---------------------------------------------------- |
|
| --------------------------------------------------- | ---------------------------- | ---------------------------------------------------- |
|
||||||
| `fakeit_City` | City name | `"Marcelside"` |
|
| `fakeit_City` | City name | `"Reno"` |
|
||||||
| `fakeit_Country` | Country name | `"United States of America"` |
|
| `fakeit_Country` | Country name | `"United States of America"` |
|
||||||
| `fakeit_CountryAbr` | Country abbreviation | `"US"` |
|
| `fakeit_CountryAbr` | Country abbreviation | `"US"` |
|
||||||
| `fakeit_State` | State name | `"Illinois"` |
|
| `fakeit_State` | State name | `"Illinois"` |
|
||||||
@@ -400,7 +402,7 @@ These functions are powered by [gofakeit](https://github.com/brianvoe/gofakeit)
|
|||||||
| `fakeit_StreetName` | Street name | `"View"` |
|
| `fakeit_StreetName` | Street name | `"View"` |
|
||||||
| `fakeit_StreetNumber` | Street number | `"13645"` |
|
| `fakeit_StreetNumber` | Street number | `"13645"` |
|
||||||
| `fakeit_StreetPrefix` | Street prefix | `"East"` |
|
| `fakeit_StreetPrefix` | Street prefix | `"East"` |
|
||||||
| `fakeit_StreetSuffix` | Street suffix | `"Ave"` |
|
| `fakeit_StreetSuffix` | Street suffix | `"side"` |
|
||||||
| `fakeit_Unit` | Unit | `"Apt 123"` |
|
| `fakeit_Unit` | Unit | `"Apt 123"` |
|
||||||
| `fakeit_Zip` | ZIP code | `"13645"` |
|
| `fakeit_Zip` | ZIP code | `"13645"` |
|
||||||
| `fakeit_Latitude` | Random latitude | `-73.534056` |
|
| `fakeit_Latitude` | Random latitude | `-73.534056` |
|
||||||
@@ -408,11 +410,23 @@ These functions are powered by [gofakeit](https://github.com/brianvoe/gofakeit)
|
|||||||
| `fakeit_LatitudeInRange(min float64, max float64)` | Latitude in specified range | `{{ fakeit_LatitudeInRange 0 90 }}` → `22.921026` |
|
| `fakeit_LatitudeInRange(min float64, max float64)` | Latitude in specified range | `{{ fakeit_LatitudeInRange 0 90 }}` → `22.921026` |
|
||||||
| `fakeit_LongitudeInRange(min float64, max float64)` | Longitude in specified range | `{{ fakeit_LongitudeInRange 0 180 }}` → `122.471830` |
|
| `fakeit_LongitudeInRange(min float64, max float64)` | Longitude in specified range | `{{ fakeit_LongitudeInRange 0 180 }}` → `122.471830` |
|
||||||
|
|
||||||
|
### Airline
|
||||||
|
|
||||||
|
| Function | Description | Example Output |
|
||||||
|
| ----------------------------- | ----------------- | ---------------------------------------------------- |
|
||||||
|
| `fakeit_AirlineAircraftType` | Aircraft type | `"narrowbody"` |
|
||||||
|
| `fakeit_AirlineAirplane` | Airplane model | `"Airbus A320"` |
|
||||||
|
| `fakeit_AirlineAirport` | Airport name | `"Hartsfield-Jackson Atlanta International Airport"` |
|
||||||
|
| `fakeit_AirlineAirportIATA` | Airport IATA code | `"ATL"` |
|
||||||
|
| `fakeit_AirlineFlightNumber` | Flight number | `"AA1234"` |
|
||||||
|
| `fakeit_AirlineRecordLocator` | Booking reference | `"ABCDEF"` |
|
||||||
|
| `fakeit_AirlineSeat` | Seat assignment | `"12A"` |
|
||||||
|
|
||||||
### Game
|
### Game
|
||||||
|
|
||||||
| Function | Description | Example Output |
|
| Function | Description | Example Output |
|
||||||
| ----------------- | ----------- | ------------------- |
|
| ----------------- | ----------- | ----------------- |
|
||||||
| `fakeit_Gamertag` | Gamer tag | `"footinterpret63"` |
|
| `fakeit_Gamertag` | Gamer tag | `"TurkeyThinker"` |
|
||||||
|
|
||||||
### Beer
|
### Beer
|
||||||
|
|
||||||
@@ -443,18 +457,22 @@ These functions are powered by [gofakeit](https://github.com/brianvoe/gofakeit)
|
|||||||
| ---------------------------------- | --------------------------- | ---------------- |
|
| ---------------------------------- | --------------------------- | ---------------- |
|
||||||
| `fakeit_Word` | Random word | `"example"` |
|
| `fakeit_Word` | Random word | `"example"` |
|
||||||
| `fakeit_Noun` | Random noun | `"computer"` |
|
| `fakeit_Noun` | Random noun | `"computer"` |
|
||||||
| `fakeit_NounCommon` | Common noun | `"table"` |
|
| `fakeit_NounCommon` | Common noun | `"group"` |
|
||||||
| `fakeit_NounConcrete` | Concrete noun | `"chair"` |
|
| `fakeit_NounConcrete` | Concrete noun | `"chair"` |
|
||||||
| `fakeit_NounAbstract` | Abstract noun | `"freedom"` |
|
| `fakeit_NounAbstract` | Abstract noun | `"freedom"` |
|
||||||
| `fakeit_NounCollectivePeople` | Collective noun (people) | `"team"` |
|
| `fakeit_NounCollectivePeople` | Collective noun (people) | `"team"` |
|
||||||
| `fakeit_NounCollectiveAnimal` | Collective noun (animal) | `"herd"` |
|
| `fakeit_NounCollectiveAnimal` | Collective noun (animal) | `"leap"` |
|
||||||
| `fakeit_NounCollectiveThing` | Collective noun (thing) | `"bunch"` |
|
| `fakeit_NounCollectiveThing` | Collective noun (thing) | `"bunch"` |
|
||||||
| `fakeit_NounCountable` | Countable noun | `"book"` |
|
| `fakeit_NounCountable` | Countable noun | `"book"` |
|
||||||
| `fakeit_NounUncountable` | Uncountable noun | `"water"` |
|
| `fakeit_NounUncountable` | Uncountable noun | `"water"` |
|
||||||
| `fakeit_Verb` | Random verb | `"run"` |
|
| `fakeit_NounProper` | Proper noun | `"John"` |
|
||||||
|
| `fakeit_NounDeterminer` | Noun determiner | `"your"` |
|
||||||
|
| `fakeit_Verb` | Random verb | `"would"` |
|
||||||
| `fakeit_VerbAction` | Action verb | `"jump"` |
|
| `fakeit_VerbAction` | Action verb | `"jump"` |
|
||||||
| `fakeit_VerbLinking` | Linking verb | `"is"` |
|
| `fakeit_VerbLinking` | Linking verb | `"is"` |
|
||||||
| `fakeit_VerbHelping` | Helping verb | `"can"` |
|
| `fakeit_VerbHelping` | Helping verb | `"can"` |
|
||||||
|
| `fakeit_VerbTransitive` | Transitive verb | `"follow"` |
|
||||||
|
| `fakeit_VerbIntransitive` | Intransitive verb | `"laugh"` |
|
||||||
| `fakeit_Adverb` | Random adverb | `"quickly"` |
|
| `fakeit_Adverb` | Random adverb | `"quickly"` |
|
||||||
| `fakeit_AdverbManner` | Manner adverb | `"carefully"` |
|
| `fakeit_AdverbManner` | Manner adverb | `"carefully"` |
|
||||||
| `fakeit_AdverbDegree` | Degree adverb | `"very"` |
|
| `fakeit_AdverbDegree` | Degree adverb | `"very"` |
|
||||||
@@ -468,7 +486,7 @@ These functions are powered by [gofakeit](https://github.com/brianvoe/gofakeit)
|
|||||||
| `fakeit_PrepositionDouble` | Double preposition | `"out of"` |
|
| `fakeit_PrepositionDouble` | Double preposition | `"out of"` |
|
||||||
| `fakeit_PrepositionCompound` | Compound preposition | `"according to"` |
|
| `fakeit_PrepositionCompound` | Compound preposition | `"according to"` |
|
||||||
| `fakeit_Adjective` | Random adjective | `"beautiful"` |
|
| `fakeit_Adjective` | Random adjective | `"beautiful"` |
|
||||||
| `fakeit_AdjectiveDescriptive` | Descriptive adjective | `"large"` |
|
| `fakeit_AdjectiveDescriptive` | Descriptive adjective | `"tired"` |
|
||||||
| `fakeit_AdjectiveQuantitative` | Quantitative adjective | `"many"` |
|
| `fakeit_AdjectiveQuantitative` | Quantitative adjective | `"many"` |
|
||||||
| `fakeit_AdjectiveProper` | Proper adjective | `"American"` |
|
| `fakeit_AdjectiveProper` | Proper adjective | `"American"` |
|
||||||
| `fakeit_AdjectiveDemonstrative` | Demonstrative adjective | `"this"` |
|
| `fakeit_AdjectiveDemonstrative` | Demonstrative adjective | `"this"` |
|
||||||
@@ -483,26 +501,33 @@ These functions are powered by [gofakeit](https://github.com/brianvoe/gofakeit)
|
|||||||
| `fakeit_PronounDemonstrative` | Demonstrative pronoun | `"that"` |
|
| `fakeit_PronounDemonstrative` | Demonstrative pronoun | `"that"` |
|
||||||
| `fakeit_PronounInterrogative` | Interrogative pronoun | `"who"` |
|
| `fakeit_PronounInterrogative` | Interrogative pronoun | `"who"` |
|
||||||
| `fakeit_PronounRelative` | Relative pronoun | `"which"` |
|
| `fakeit_PronounRelative` | Relative pronoun | `"which"` |
|
||||||
|
| `fakeit_PronounIndefinite` | Indefinite pronoun | `"few"` |
|
||||||
| `fakeit_Connective` | Random connective | `"however"` |
|
| `fakeit_Connective` | Random connective | `"however"` |
|
||||||
| `fakeit_ConnectiveTime` | Time connective | `"then"` |
|
| `fakeit_ConnectiveTime` | Time connective | `"then"` |
|
||||||
| `fakeit_ConnectiveComparative` | Comparative connective | `"similarly"` |
|
| `fakeit_ConnectiveComparative` | Comparative connective | `"after all"` |
|
||||||
| `fakeit_ConnectiveComplaint` | Complaint connective | `"although"` |
|
| `fakeit_ConnectiveComplaint` | Complaint connective | `"i.e."` |
|
||||||
| `fakeit_ConnectiveListing` | Listing connective | `"firstly"` |
|
| `fakeit_ConnectiveListing` | Listing connective | `"firstly"` |
|
||||||
| `fakeit_ConnectiveCasual` | Casual connective | `"because"` |
|
| `fakeit_ConnectiveCasual` | Casual connective | `"because"` |
|
||||||
| `fakeit_ConnectiveExamplify` | Examplify connective | `"for example"` |
|
| `fakeit_ConnectiveExamplify` | Examplify connective | `"for example"` |
|
||||||
|
| `fakeit_Interjection` | Interjection | `"wow"` |
|
||||||
|
|
||||||
### Text
|
### Text
|
||||||
|
|
||||||
| Function | Description | Example |
|
| Function | Description | Example |
|
||||||
| ---------------------------------------------------------------------------------------- | ----------------------------------------------- | ----------------------------------------------------- |
|
| ---------------------------------------------------------------------------------------- | ----------------------------------------------- | --------------------------------------------- |
|
||||||
| `fakeit_Sentence(wordCount ...int)` | Random sentence (optional word count) | `{{ fakeit_Sentence }}` or `{{ fakeit_Sentence 10 }}` |
|
| `fakeit_Sentence` | Random sentence | `{{ fakeit_Sentence }}` |
|
||||||
| `fakeit_Paragraph` | Random paragraph | `{{ fakeit_Paragraph }}` |
|
| `fakeit_Paragraph` | Random paragraph | `{{ fakeit_Paragraph }}` |
|
||||||
| `fakeit_LoremIpsumWord` | Lorem ipsum word | `"lorem"` |
|
| `fakeit_LoremIpsumWord` | Lorem ipsum word | `"eveniet"` |
|
||||||
| `fakeit_LoremIpsumSentence(wordCount int)` | Lorem ipsum sentence with specified word count | `{{ fakeit_LoremIpsumSentence 5 }}` |
|
| `fakeit_LoremIpsumSentence(wordCount int)` | Lorem ipsum sentence with specified word count | `{{ fakeit_LoremIpsumSentence 5 }}` |
|
||||||
| `fakeit_LoremIpsumParagraph(paragraphs int, sentences int, words int, separator string)` | Lorem ipsum paragraphs with specified structure | `{{ fakeit_LoremIpsumParagraph 1 3 5 "\n" }}` |
|
| `fakeit_LoremIpsumParagraph(paragraphs int, sentences int, words int, separator string)` | Lorem ipsum paragraphs with specified structure | `{{ fakeit_LoremIpsumParagraph 1 3 5 "\n" }}` |
|
||||||
| `fakeit_Question` | Random question | `"What is your name?"` |
|
| `fakeit_Question` | Random question | `"What is the marginal gain from fear?"` |
|
||||||
| `fakeit_Quote` | Random quote | `"Life is what happens..."` |
|
| `fakeit_Quote` | Random quote | `"Energy is contagious—so is fear"` |
|
||||||
| `fakeit_Phrase` | Random phrase | `"a piece of cake"` |
|
| `fakeit_Phrase` | Random phrase | `"how many siblings do you have"` |
|
||||||
|
| `fakeit_PhraseNoun` | Noun phrase | `"a tribe"` |
|
||||||
|
| `fakeit_PhraseVerb` | Verb phrase | `"fully integrate a system"` |
|
||||||
|
| `fakeit_PhraseAdverb` | Adverb phrase | `"fully gladly"` |
|
||||||
|
| `fakeit_PhrasePreposition` | Preposition phrase | `"out the black thing"` |
|
||||||
|
| `fakeit_Comment` | Comment | `"add some a little bit team"` |
|
||||||
|
|
||||||
### Foods
|
### Foods
|
||||||
|
|
||||||
@@ -515,6 +540,7 @@ These functions are powered by [gofakeit](https://github.com/brianvoe/gofakeit)
|
|||||||
| `fakeit_Dinner` | Dinner food | `"Wild addicting dip"` |
|
| `fakeit_Dinner` | Dinner food | `"Wild addicting dip"` |
|
||||||
| `fakeit_Snack` | Snack | `"Trail mix"` |
|
| `fakeit_Snack` | Snack | `"Trail mix"` |
|
||||||
| `fakeit_Dessert` | Dessert | `"French napoleons"` |
|
| `fakeit_Dessert` | Dessert | `"French napoleons"` |
|
||||||
|
| `fakeit_Drink` | Drink | `"Soda"` |
|
||||||
|
|
||||||
### Misc
|
### Misc
|
||||||
|
|
||||||
@@ -525,20 +551,23 @@ These functions are powered by [gofakeit](https://github.com/brianvoe/gofakeit)
|
|||||||
|
|
||||||
### Color
|
### Color
|
||||||
|
|
||||||
| Function | Description | Example Output |
|
| Function | Description | Example Output |
|
||||||
| ------------------- | ------------------ | --------------------------------------------------------- |
|
| ------------------- | ------------------ | ------------------------------------------- |
|
||||||
| `fakeit_Color` | Color name | `"MediumOrchid"` |
|
| `fakeit_Color` | Color name | `"MediumOrchid"` |
|
||||||
| `fakeit_HexColor` | Hex color | `"#a99fb4"` |
|
| `fakeit_HexColor` | Hex color | `"#a99fb4"` |
|
||||||
| `fakeit_RGBColor` | RGB color | `[85, 224, 195]` |
|
| `fakeit_RGBColor` | RGB color | `[85 224 195]` |
|
||||||
| `fakeit_SafeColor` | Safe color | `"black"` |
|
| `fakeit_HSLColor` | HSL color | `[210 85 50]` |
|
||||||
| `fakeit_NiceColors` | Nice color palette | `["#cfffdd", "#b4dec1", "#5c5863", "#a85163", "#ff1f4c"]` |
|
| `fakeit_SafeColor` | Safe color | `"black"` |
|
||||||
|
| `fakeit_NiceColors` | Nice color palette | `[#cfffdd #b4dec1 #5c5863 #a85163 #ff1f4c]` |
|
||||||
|
|
||||||
### Image
|
### Image
|
||||||
|
|
||||||
| Function | Description | Example |
|
| Function | Description | Example |
|
||||||
| ----------------------------------------- | ------------------------- | -------------------------------- |
|
| ----------------------------------------- | -------------------------- | -------------------------------- |
|
||||||
| `fakeit_ImageJpeg(width int, height int)` | Generate JPEG image bytes | `{{ fakeit_ImageJpeg 100 100 }}` |
|
| `fakeit_ImageJpeg(width int, height int)` | Generate a JPEG byte slice | `{{ fakeit_ImageJpeg 100 100 }}` |
|
||||||
| `fakeit_ImagePng(width int, height int)` | Generate PNG image bytes | `{{ fakeit_ImagePng 100 100 }}` |
|
| `fakeit_ImagePng(width int, height int)` | Generate a PNG byte slice | `{{ fakeit_ImagePng 100 100 }}` |
|
||||||
|
|
||||||
|
> **Note:** Go templates render byte slices as decimal lists, not raw binary image data. Use `{{ json_Encode (fakeit_ImagePng 100 100) }}` to produce a Base64-encoded JSON string. These functions cannot write raw image bytes directly through body templating.
|
||||||
|
|
||||||
### Internet
|
### Internet
|
||||||
|
|
||||||
@@ -567,16 +596,16 @@ These functions are powered by [gofakeit](https://github.com/brianvoe/gofakeit)
|
|||||||
|
|
||||||
| Function | Description | Example Output |
|
| Function | Description | Example Output |
|
||||||
| ------------------ | --------------- | ------------------ |
|
| ------------------ | --------------- | ------------------ |
|
||||||
| `fakeit_InputName` | HTML input name | `"email"` |
|
| `fakeit_InputName` | HTML input name | `"message"` |
|
||||||
| `fakeit_Svg` | SVG image | `"<svg>...</svg>"` |
|
| `fakeit_Svg` | SVG image | `"<svg>...</svg>"` |
|
||||||
|
|
||||||
### Date/Time
|
### Date/Time
|
||||||
|
|
||||||
| Function | Description | Example |
|
| Function | Description | Example |
|
||||||
| -------------------------------------------------- | --------------------------------- | ------------------------------------------------------------------------------------ |
|
| -------------------------------------------------- | --------------------------------- | ------------------------------------------------------------------------------------ |
|
||||||
| `fakeit_Date` | Random date | `2023-06-15 14:30:00` |
|
| `fakeit_Date` | Random date | `2013-11-07 04:31:13.726582492 +0000 UTC` |
|
||||||
| `fakeit_PastDate` | Past date | `2022-03-10 09:15:00` |
|
| `fakeit_PastDate` | Date 1–12 hours before now | Current time − 1–12 hours |
|
||||||
| `fakeit_FutureDate` | Future date | `2025-12-20 18:45:00` |
|
| `fakeit_FutureDate` | Date 1–12 hours after now | Current time + 1–12 hours |
|
||||||
| `fakeit_DateRange(start time.Time, end time.Time)` | Random date between start and end | `{{ fakeit_DateRange (strings_ToDate "2020-01-01") (strings_ToDate "2025-12-31") }}` |
|
| `fakeit_DateRange(start time.Time, end time.Time)` | Random date between start and end | `{{ fakeit_DateRange (strings_ToDate "2020-01-01") (strings_ToDate "2025-12-31") }}` |
|
||||||
| `fakeit_NanoSecond` | Nanosecond | `123456789` |
|
| `fakeit_NanoSecond` | Nanosecond | `123456789` |
|
||||||
| `fakeit_Second` | Second (0-59) | `45` |
|
| `fakeit_Second` | Second (0-59) | `45` |
|
||||||
@@ -587,11 +616,11 @@ These functions are powered by [gofakeit](https://github.com/brianvoe/gofakeit)
|
|||||||
| `fakeit_Day` | Day (1-31) | `15` |
|
| `fakeit_Day` | Day (1-31) | `15` |
|
||||||
| `fakeit_WeekDay` | Weekday | `"Monday"` |
|
| `fakeit_WeekDay` | Weekday | `"Monday"` |
|
||||||
| `fakeit_Year` | Year | `2024` |
|
| `fakeit_Year` | Year | `2024` |
|
||||||
| `fakeit_TimeZone` | Timezone | `"America/New_York"` |
|
| `fakeit_TimeZone` | Timezone name | `"West Pacific Standard Time"` |
|
||||||
| `fakeit_TimeZoneAbv` | Timezone abbreviation | `"EST"` |
|
| `fakeit_TimeZoneAbv` | Timezone abbreviation | `"EST"` |
|
||||||
| `fakeit_TimeZoneFull` | Full timezone | `"Eastern Standard Time"` |
|
| `fakeit_TimeZoneFull` | Full timezone | `"(UTC+10:00) Guam, Port Moresby"` |
|
||||||
| `fakeit_TimeZoneOffset` | Timezone offset | `-5` |
|
| `fakeit_TimeZoneOffset` | Timezone offset | `-5` |
|
||||||
| `fakeit_TimeZoneRegion` | Timezone region | `"America"` |
|
| `fakeit_TimeZoneRegion` | Timezone region | `"Indian/Chagos"` |
|
||||||
|
|
||||||
### Payment
|
### Payment
|
||||||
|
|
||||||
@@ -607,8 +636,8 @@ These functions are powered by [gofakeit](https://github.com/brianvoe/gofakeit)
|
|||||||
| `fakeit_AchRouting` | ACH routing number | `"513715684"` |
|
| `fakeit_AchRouting` | ACH routing number | `"513715684"` |
|
||||||
| `fakeit_AchAccount` | ACH account number | `"491527954328"` |
|
| `fakeit_AchAccount` | ACH account number | `"491527954328"` |
|
||||||
| `fakeit_BitcoinAddress` | Bitcoin address | `"1BoatSLRHtKNngkdXEeobR76b53LETtpyT"` |
|
| `fakeit_BitcoinAddress` | Bitcoin address | `"1BoatSLRHtKNngkdXEeobR76b53LETtpyT"` |
|
||||||
| `fakeit_BitcoinPrivateKey` | Bitcoin private key | `"5HueCGU8rMjxEXxiPuD5BDuG6o5xjA7QkbPp"` |
|
| `fakeit_BitcoinPrivateKey` | Bitcoin private key | `"5JMZxkQX2PgaasaHc8wnWLNdMu7rxeU7xS64ev7RWNinacicPfm"` |
|
||||||
| `fakeit_BankName` | Bank name | `"Wells Fargo"` |
|
| `fakeit_BankName` | Bank name | `"Toronto Dominion Bank"` |
|
||||||
| `fakeit_BankType` | Bank type | `"Investment Bank"` |
|
| `fakeit_BankType` | Bank type | `"Investment Bank"` |
|
||||||
|
|
||||||
### Finance
|
### Finance
|
||||||
@@ -620,17 +649,17 @@ These functions are powered by [gofakeit](https://github.com/brianvoe/gofakeit)
|
|||||||
|
|
||||||
### Company
|
### Company
|
||||||
|
|
||||||
| Function | Description | Example Output |
|
| Function | Description | Example Output |
|
||||||
| ---------------------- | -------------- | ------------------------------------------ |
|
| ---------------------- | -------------- | ---------------------- |
|
||||||
| `fakeit_BS` | Business speak | `"front-end"` |
|
| `fakeit_BS` | Business speak | `"front-end"` |
|
||||||
| `fakeit_Blurb` | Company blurb | `"word"` |
|
| `fakeit_Blurb` | Company blurb | `"Teamwork"` |
|
||||||
| `fakeit_BuzzWord` | Buzzword | `"disintermediate"` |
|
| `fakeit_BuzzWord` | Buzzword | `"disintermediate"` |
|
||||||
| `fakeit_Company` | Company name | `"Moen, Pagac and Wuckert"` |
|
| `fakeit_Company` | Company name | `"TransparaGov"` |
|
||||||
| `fakeit_CompanySuffix` | Company suffix | `"Inc"` |
|
| `fakeit_CompanySuffix` | Company suffix | `"Inc"` |
|
||||||
| `fakeit_JobDescriptor` | Job descriptor | `"Central"` |
|
| `fakeit_JobDescriptor` | Job descriptor | `"Central"` |
|
||||||
| `fakeit_JobLevel` | Job level | `"Assurance"` |
|
| `fakeit_JobLevel` | Job level | `"Assurance"` |
|
||||||
| `fakeit_JobTitle` | Job title | `"Director"` |
|
| `fakeit_JobTitle` | Job title | `"Director"` |
|
||||||
| `fakeit_Slogan` | Company slogan | `"Universal seamless Focus, interactive."` |
|
| `fakeit_Slogan` | Company slogan | `"Made of styrofoam."` |
|
||||||
|
|
||||||
### Hacker
|
### Hacker
|
||||||
|
|
||||||
@@ -695,9 +724,9 @@ These functions are powered by [gofakeit](https://github.com/brianvoe/gofakeit)
|
|||||||
| `fakeit_EmojiTools` | Tools emoji | `"🔧"` |
|
| `fakeit_EmojiTools` | Tools emoji | `"🔧"` |
|
||||||
| `fakeit_EmojiWeather` | Weather emoji | `"☀️"` |
|
| `fakeit_EmojiWeather` | Weather emoji | `"☀️"` |
|
||||||
| `fakeit_EmojiJob` | Job emoji | `"👨💻"` |
|
| `fakeit_EmojiJob` | Job emoji | `"👨💻"` |
|
||||||
| `fakeit_EmojiPerson` | Person emoji | `"👤"` |
|
| `fakeit_EmojiPerson` | Person emoji | `"🧓"` |
|
||||||
| `fakeit_EmojiGesture` | Gesture emoji | `"🙌"` |
|
| `fakeit_EmojiGesture` | Gesture emoji | `"🤦♀️"` |
|
||||||
| `fakeit_EmojiCostume` | Costume emoji | `"🎃"` |
|
| `fakeit_EmojiCostume` | Costume emoji | `"🧞"` |
|
||||||
| `fakeit_EmojiSentence` | Emoji sentence with random emojis interspersed | `"Weekends reserve time for 🖼️ Disc 🏨 golf and day."` |
|
| `fakeit_EmojiSentence` | Emoji sentence with random emojis interspersed | `"Weekends reserve time for 🖼️ Disc 🏨 golf and day."` |
|
||||||
|
|
||||||
### Language
|
### Language
|
||||||
@@ -706,31 +735,35 @@ These functions are powered by [gofakeit](https://github.com/brianvoe/gofakeit)
|
|||||||
| ----------------------------- | --------------------- | -------------- |
|
| ----------------------------- | --------------------- | -------------- |
|
||||||
| `fakeit_Language` | Language | `"English"` |
|
| `fakeit_Language` | Language | `"English"` |
|
||||||
| `fakeit_LanguageAbbreviation` | Language abbreviation | `"en"` |
|
| `fakeit_LanguageAbbreviation` | Language abbreviation | `"en"` |
|
||||||
|
| `fakeit_LanguageBCP` | BCP language tag | `"en-US"` |
|
||||||
| `fakeit_ProgrammingLanguage` | Programming language | `"Go"` |
|
| `fakeit_ProgrammingLanguage` | Programming language | `"Go"` |
|
||||||
|
|
||||||
### Number
|
### Number
|
||||||
|
|
||||||
| Function | Description | Example |
|
| Function | Description | Example |
|
||||||
| ----------------------------------------------- | ----------------------------------- | ------------------------------------------ |
|
| ----------------------------------------------- | ----------------------------------- | -------------------------------------------- |
|
||||||
| `fakeit_Number(min int, max int)` | Random number in range | `{{ fakeit_Number 1 100 }}` → `42` |
|
| `fakeit_Number(min int, max int)` | Random number in range | `{{ fakeit_Number 1 100 }}` → `42` |
|
||||||
| `fakeit_Int` | Random int | `{{ fakeit_Int }}` |
|
| `fakeit_Int` | Random int | `{{ fakeit_Int }}` |
|
||||||
| `fakeit_IntN(n int)` | Random int from 0 to n | `{{ fakeit_IntN 100 }}` |
|
| `fakeit_IntN(n int)` | Random int in `[0, n)` | `{{ fakeit_IntN 100 }}` |
|
||||||
| `fakeit_Int8` | Random int8 | `{{ fakeit_Int8 }}` |
|
| `fakeit_Int8` | Random int8 | `{{ fakeit_Int8 }}` |
|
||||||
| `fakeit_Int16` | Random int16 | `{{ fakeit_Int16 }}` |
|
| `fakeit_Int16` | Random int16 | `{{ fakeit_Int16 }}` |
|
||||||
| `fakeit_Int32` | Random int32 | `{{ fakeit_Int32 }}` |
|
| `fakeit_Int32` | Random int32 | `{{ fakeit_Int32 }}` |
|
||||||
| `fakeit_Int64` | Random int64 | `{{ fakeit_Int64 }}` |
|
| `fakeit_Int64` | Random int64 | `{{ fakeit_Int64 }}` |
|
||||||
| `fakeit_Uint` | Random uint | `{{ fakeit_Uint }}` |
|
| `fakeit_IntRange(min int, max int)` | Random int in range | `{{ fakeit_IntRange -10 10 }}` |
|
||||||
| `fakeit_UintN(n uint)` | Random uint from 0 to n | `{{ fakeit_UintN 100 }}` |
|
| `fakeit_Uint` | Random uint | `{{ fakeit_Uint }}` |
|
||||||
| `fakeit_Uint8` | Random uint8 | `{{ fakeit_Uint8 }}` |
|
| `fakeit_UintN(n uint)` | Random uint in `[0, n)` | `{{ fakeit_UintN 100 }}` |
|
||||||
| `fakeit_Uint16` | Random uint16 | `{{ fakeit_Uint16 }}` |
|
| `fakeit_Uint8` | Random uint8 | `{{ fakeit_Uint8 }}` |
|
||||||
| `fakeit_Uint32` | Random uint32 | `{{ fakeit_Uint32 }}` |
|
| `fakeit_Uint16` | Random uint16 | `{{ fakeit_Uint16 }}` |
|
||||||
| `fakeit_Uint64` | Random uint64 | `{{ fakeit_Uint64 }}` |
|
| `fakeit_Uint32` | Random uint32 | `{{ fakeit_Uint32 }}` |
|
||||||
| `fakeit_Float32` | Random float32 | `{{ fakeit_Float32 }}` |
|
| `fakeit_Uint64` | Random uint64 | `{{ fakeit_Uint64 }}` |
|
||||||
| `fakeit_Float32Range(min float32, max float32)` | Random float32 in range | `{{ fakeit_Float32Range 0 100 }}` |
|
| `fakeit_UintRange(min uint, max uint)` | Random uint in range | `{{ fakeit_UintRange 10 100 }}` |
|
||||||
| `fakeit_Float64` | Random float64 | `{{ fakeit_Float64 }}` |
|
| `fakeit_Float32` | Random float32 | `{{ fakeit_Float32 }}` |
|
||||||
| `fakeit_Float64Range(min float64, max float64)` | Random float64 in range | `{{ fakeit_Float64Range 0 100 }}` |
|
| `fakeit_Float32Range(min float32, max float32)` | Random float32 in range | `{{ fakeit_Float32Range 0 100 }}` |
|
||||||
| `fakeit_RandomInt(slice []int)` | Random int from slice | `{{ fakeit_RandomInt (slice_Int 1 2 3) }}` |
|
| `fakeit_Float64` | Random float64 | `{{ fakeit_Float64 }}` |
|
||||||
| `fakeit_HexUint(bits int)` | Random hex uint with specified bits | `{{ fakeit_HexUint 8 }}` → `"0xff"` |
|
| `fakeit_Float64Range(min float64, max float64)` | Random float64 in range | `{{ fakeit_Float64Range 0 100 }}` |
|
||||||
|
| `fakeit_RandomInt(slice []int)` | Random int from slice | `{{ fakeit_RandomInt (slice_Int 1 2 3) }}` |
|
||||||
|
| `fakeit_RandomUint(slice []uint)` | Random uint from slice | `{{ fakeit_RandomUint (slice_Uint 1 2 3) }}` |
|
||||||
|
| `fakeit_HexUint(bits int)` | Random hex uint with specified bits | `{{ fakeit_HexUint 8 }}` → `"0xff"` |
|
||||||
|
|
||||||
### String
|
### String
|
||||||
|
|
||||||
@@ -740,6 +773,7 @@ These functions are powered by [gofakeit](https://github.com/brianvoe/gofakeit)
|
|||||||
| `fakeit_DigitN(n uint)` | Generate `n` random digits | `{{ fakeit_DigitN 5 }}` → `"71364"` |
|
| `fakeit_DigitN(n uint)` | Generate `n` random digits | `{{ fakeit_DigitN 5 }}` → `"71364"` |
|
||||||
| `fakeit_Letter` | Single random letter | `"g"` |
|
| `fakeit_Letter` | Single random letter | `"g"` |
|
||||||
| `fakeit_LetterN(n uint)` | Generate `n` random letters | `{{ fakeit_LetterN 10 }}` → `"gbRMaRxHki"` |
|
| `fakeit_LetterN(n uint)` | Generate `n` random letters | `{{ fakeit_LetterN 10 }}` → `"gbRMaRxHki"` |
|
||||||
|
| `fakeit_Vowel` | Single lowercase vowel | `"a"` |
|
||||||
| `fakeit_Lexify(pattern string)` | Replace `?` with random letters | `{{ fakeit_Lexify "?????@??????.com" }}` → `"billy@mister.com"` |
|
| `fakeit_Lexify(pattern string)` | Replace `?` with random letters | `{{ fakeit_Lexify "?????@??????.com" }}` → `"billy@mister.com"` |
|
||||||
| `fakeit_Numerify(pattern string)` | Replace `#` with random digits | `{{ fakeit_Numerify "(###)###-####" }}` → `"(555)867-5309"` |
|
| `fakeit_Numerify(pattern string)` | Replace `#` with random digits | `{{ fakeit_Numerify "(###)###-####" }}` → `"(555)867-5309"` |
|
||||||
| `fakeit_RandomString(slice []string)` | Random string from slice | `{{ fakeit_RandomString (slice_Str "a" "b" "c") }}` |
|
| `fakeit_RandomString(slice []string)` | Random string from slice | `{{ fakeit_RandomString (slice_Str "a" "b" "c") }}` |
|
||||||
@@ -754,26 +788,26 @@ These functions are powered by [gofakeit](https://github.com/brianvoe/gofakeit)
|
|||||||
|
|
||||||
### Minecraft
|
### Minecraft
|
||||||
|
|
||||||
| Function | Description | Example Output |
|
| Function | Description | Example Output |
|
||||||
| --------------------------------- | ----------------- | ---------------- |
|
| --------------------------------- | ----------------- | ------------------- |
|
||||||
| `fakeit_MinecraftOre` | Minecraft ore | `"coal"` |
|
| `fakeit_MinecraftOre` | Minecraft ore | `"coal"` |
|
||||||
| `fakeit_MinecraftWood` | Minecraft wood | `"oak"` |
|
| `fakeit_MinecraftWood` | Minecraft wood | `"oak"` |
|
||||||
| `fakeit_MinecraftArmorTier` | Armor tier | `"iron"` |
|
| `fakeit_MinecraftArmorTier` | Armor tier | `"iron"` |
|
||||||
| `fakeit_MinecraftArmorPart` | Armor part | `"helmet"` |
|
| `fakeit_MinecraftArmorPart` | Armor part | `"helmet"` |
|
||||||
| `fakeit_MinecraftWeapon` | Minecraft weapon | `"bow"` |
|
| `fakeit_MinecraftWeapon` | Minecraft weapon | `"bow"` |
|
||||||
| `fakeit_MinecraftTool` | Minecraft tool | `"shovel"` |
|
| `fakeit_MinecraftTool` | Minecraft tool | `"shovel"` |
|
||||||
| `fakeit_MinecraftDye` | Minecraft dye | `"white"` |
|
| `fakeit_MinecraftDye` | Minecraft dye | `"white"` |
|
||||||
| `fakeit_MinecraftFood` | Minecraft food | `"apple"` |
|
| `fakeit_MinecraftFood` | Minecraft food | `"apple"` |
|
||||||
| `fakeit_MinecraftAnimal` | Minecraft animal | `"chicken"` |
|
| `fakeit_MinecraftAnimal` | Minecraft animal | `"chicken"` |
|
||||||
| `fakeit_MinecraftVillagerJob` | Villager job | `"farmer"` |
|
| `fakeit_MinecraftVillagerJob` | Villager job | `"farmer"` |
|
||||||
| `fakeit_MinecraftVillagerStation` | Villager station | `"furnace"` |
|
| `fakeit_MinecraftVillagerStation` | Villager station | `"stonecutter"` |
|
||||||
| `fakeit_MinecraftVillagerLevel` | Villager level | `"master"` |
|
| `fakeit_MinecraftVillagerLevel` | Villager level | `"master"` |
|
||||||
| `fakeit_MinecraftMobPassive` | Passive mob | `"cow"` |
|
| `fakeit_MinecraftMobPassive` | Passive mob | `"cow"` |
|
||||||
| `fakeit_MinecraftMobNeutral` | Neutral mob | `"bee"` |
|
| `fakeit_MinecraftMobNeutral` | Neutral mob | `"bee"` |
|
||||||
| `fakeit_MinecraftMobHostile` | Hostile mob | `"spider"` |
|
| `fakeit_MinecraftMobHostile` | Hostile mob | `"wither skeleton"` |
|
||||||
| `fakeit_MinecraftMobBoss` | Boss mob | `"ender dragon"` |
|
| `fakeit_MinecraftMobBoss` | Boss mob | `"ender dragon"` |
|
||||||
| `fakeit_MinecraftBiome` | Minecraft biome | `"forest"` |
|
| `fakeit_MinecraftBiome` | Minecraft biome | `"forest"` |
|
||||||
| `fakeit_MinecraftWeather` | Minecraft weather | `"rain"` |
|
| `fakeit_MinecraftWeather` | Minecraft weather | `"rain"` |
|
||||||
|
|
||||||
### Book
|
### Book
|
||||||
|
|
||||||
@@ -792,26 +826,28 @@ These functions are powered by [gofakeit](https://github.com/brianvoe/gofakeit)
|
|||||||
|
|
||||||
### Error
|
### Error
|
||||||
|
|
||||||
| Function | Description | Example Output |
|
| Function | Description | Example Output |
|
||||||
| ------------------------ | ----------------- | ---------------------------------- |
|
| ------------------------ | ----------------- | ----------------------------------------------- |
|
||||||
| `fakeit_Error` | Random error | `"connection refused"` |
|
| `fakeit_Error` | Random error | `"variable assigned before declaration"` |
|
||||||
| `fakeit_ErrorDatabase` | Database error | `"database connection failed"` |
|
| `fakeit_ErrorObject` | Error object | `"protocol"` |
|
||||||
| `fakeit_ErrorGRPC` | gRPC error | `"rpc error: code = Unavailable"` |
|
| `fakeit_ErrorDatabase` | Database error | `"destination pointer is nil"` |
|
||||||
| `fakeit_ErrorHTTP` | HTTP error | `"HTTP 500 Internal Server Error"` |
|
| `fakeit_ErrorGRPC` | gRPC error | `"connection refused"` |
|
||||||
| `fakeit_ErrorHTTPClient` | HTTP client error | `"HTTP 404 Not Found"` |
|
| `fakeit_ErrorHTTP` | HTTP error | `"wrote more than the declared Content-Length"` |
|
||||||
| `fakeit_ErrorHTTPServer` | HTTP server error | `"HTTP 503 Service Unavailable"` |
|
| `fakeit_ErrorHTTPClient` | HTTP client error | `"expectation failed"` |
|
||||||
| `fakeit_ErrorRuntime` | Runtime error | `"panic: runtime error"` |
|
| `fakeit_ErrorHTTPServer` | HTTP server error | `"not extended"` |
|
||||||
|
| `fakeit_ErrorRuntime` | Runtime error | `"expected 2 arguments, got 3"` |
|
||||||
|
| `fakeit_ErrorValidation` | Validation error | `"missing required field"` |
|
||||||
|
|
||||||
### School
|
### School
|
||||||
|
|
||||||
| Function | Description | Example Output |
|
| Function | Description | Example Output |
|
||||||
| --------------- | ----------- | ---------------------- |
|
| --------------- | ----------- | ---------------------------- |
|
||||||
| `fakeit_School` | School name | `"Harvard University"` |
|
| `fakeit_School` | School name | `"Hillside Private Academy"` |
|
||||||
|
|
||||||
### Song
|
### Song
|
||||||
|
|
||||||
| Function | Description | Example Output |
|
| Function | Description | Example Output |
|
||||||
| ------------------- | ----------- | --------------------- |
|
| ------------------- | ----------- | ------------------------ |
|
||||||
| `fakeit_SongName` | Song name | `"Bohemian Rhapsody"` |
|
| `fakeit_SongName` | Song name | `"What Was I Made For?"` |
|
||||||
| `fakeit_SongArtist` | Song artist | `"Queen"` |
|
| `fakeit_SongArtist` | Song artist | `"Queen"` |
|
||||||
| `fakeit_SongGenre` | Song genre | `"Rock"` |
|
| `fakeit_SongGenre` | Song genre | `"Rock"` |
|
||||||
Generated
+3
-3
@@ -2,11 +2,11 @@
|
|||||||
"nodes": {
|
"nodes": {
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1784796856,
|
"lastModified": 1789006805,
|
||||||
"narHash": "sha256-wWFrV5/Qbm+lyt5x20E/bSbfJiGKMo4RCxZV8cl/WZI=",
|
"narHash": "sha256-xB8mKMOx1IA9vTDNLmJZ6n4wCMq/cuWBBOzGCRnqxrU=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "e2587caef70cea85dd97d7daab492899902dbf5d",
|
"rev": "8ce4ef6cb6f871616146b9fe26d2a5ae594e94fe",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
@@ -32,18 +32,18 @@
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
# nix run github:aykhans/sarin -- <args>
|
# nix run github:aykhans/sarin/release -- <args>
|
||||||
apps = forAllSystems (pkgs: {
|
apps = forAllSystems (pkgs: {
|
||||||
default = {
|
default = {
|
||||||
type = "app";
|
type = "app";
|
||||||
program = "${self.packages.${pkgs.system}.default}/bin/sarin";
|
program = "${self.packages.${pkgs.stdenv.hostPlatform.system}.default}/bin/sarin";
|
||||||
meta.description = "High-performance HTTP load testing tool";
|
meta.description = "High-performance HTTP load testing tool";
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
devShells = forAllSystems (pkgs: {
|
devShells = forAllSystems (pkgs: {
|
||||||
default = pkgs.mkShell {
|
default = pkgs.mkShell {
|
||||||
packages = [ pkgs.go_1_26 pkgs.golangci-lint pkgs.go-task ];
|
packages = [ pkgs.go_1_27 pkgs.golangci-lint pkgs.go-task ];
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,58 +1,53 @@
|
|||||||
module go.aykhans.me/sarin
|
module go.aykhans.me/sarin
|
||||||
|
|
||||||
go 1.26.5
|
go 1.27.1
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/brianvoe/gofakeit/v7 v7.15.0
|
charm.land/bubbles/v2 v2.2.1
|
||||||
github.com/charmbracelet/bubbles v1.0.0
|
charm.land/bubbletea/v2 v2.0.10
|
||||||
github.com/charmbracelet/bubbletea v1.3.10
|
charm.land/glamour/v2 v2.0.1
|
||||||
github.com/charmbracelet/glamour v1.0.0
|
charm.land/lipgloss/v2 v2.0.6
|
||||||
github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834
|
github.com/brianvoe/gofakeit/v7 v7.17.1
|
||||||
github.com/charmbracelet/x/term v0.2.2
|
github.com/charmbracelet/x/term v0.2.2
|
||||||
github.com/dop251/goja v0.0.0-20260723142020-b4aef50fa347
|
github.com/dop251/goja v0.0.0-20260911104922-fabc3b8078ad
|
||||||
github.com/joho/godotenv v1.5.1
|
github.com/joho/godotenv v1.5.1
|
||||||
github.com/valyala/fasthttp v1.72.0
|
github.com/valyala/fasthttp v1.74.0
|
||||||
github.com/yuin/gopher-lua v1.1.2
|
github.com/yuin/gopher-lua v1.1.2
|
||||||
go.aykhans.me/utils v1.0.7
|
go.aykhans.me/utils v1.0.7
|
||||||
go.yaml.in/yaml/v4 v4.0.0-rc.6
|
go.yaml.in/yaml/v4 v4.0.0-rc.6
|
||||||
golang.org/x/net v0.57.0
|
golang.org/x/net v0.59.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/alecthomas/chroma/v2 v2.27.0 // indirect
|
github.com/alecthomas/chroma/v2 v2.27.0 // indirect
|
||||||
github.com/andybalholm/brotli v1.2.2 // indirect
|
|
||||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
|
|
||||||
github.com/aymerick/douceur v0.2.0 // indirect
|
github.com/aymerick/douceur v0.2.0 // indirect
|
||||||
github.com/charmbracelet/colorprofile v0.4.3 // indirect
|
github.com/charmbracelet/colorprofile v0.4.3 // indirect
|
||||||
github.com/charmbracelet/harmonica v0.2.0 // indirect
|
github.com/charmbracelet/harmonica v0.2.0 // indirect
|
||||||
github.com/charmbracelet/x/ansi v0.11.7 // indirect
|
github.com/charmbracelet/ultraviolet v0.0.0-20260910203606-6c9e17dc7a16 // indirect
|
||||||
github.com/charmbracelet/x/cellbuf v0.0.15 // indirect
|
github.com/charmbracelet/x/ansi v0.11.8 // indirect
|
||||||
github.com/charmbracelet/x/exp/slice v0.0.0-20260726004341-482a56510f1b // indirect
|
github.com/charmbracelet/x/exp/slice v0.0.0-20260906004030-3986e9119cf9 // indirect
|
||||||
|
github.com/charmbracelet/x/termios v0.1.1 // indirect
|
||||||
|
github.com/charmbracelet/x/windows v0.2.2 // indirect
|
||||||
github.com/clipperhouse/displaywidth v0.11.0 // indirect
|
github.com/clipperhouse/displaywidth v0.11.0 // indirect
|
||||||
github.com/clipperhouse/uax29/v2 v2.7.0 // indirect
|
github.com/clipperhouse/uax29/v2 v2.7.0 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||||
github.com/dlclark/regexp2/v2 v2.5.2 // indirect
|
github.com/dlclark/regexp2/v2 v2.8.0 // indirect
|
||||||
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
|
|
||||||
github.com/go-sourcemap/sourcemap v2.1.4+incompatible // indirect
|
github.com/go-sourcemap/sourcemap v2.1.4+incompatible // indirect
|
||||||
github.com/google/pprof v0.0.0-20260709232956-b9395ee17fa0 // indirect
|
github.com/google/pprof v0.0.0-20260906184651-6331bc6350fe // indirect
|
||||||
github.com/gorilla/css v1.0.1 // indirect
|
github.com/gorilla/css v1.0.1 // indirect
|
||||||
github.com/klauspost/compress v1.19.1 // indirect
|
github.com/klauspost/compress v1.20.0 // indirect
|
||||||
github.com/lucasb-eyer/go-colorful v1.4.0 // indirect
|
github.com/lucasb-eyer/go-colorful v1.4.1 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.24 // indirect
|
github.com/mattn/go-runewidth v0.0.30 // indirect
|
||||||
github.com/mattn/go-localereader v0.0.1 // indirect
|
|
||||||
github.com/mattn/go-runewidth v0.0.27 // indirect
|
|
||||||
github.com/microcosm-cc/bluemonday v1.0.27 // indirect
|
github.com/microcosm-cc/bluemonday v1.0.27 // indirect
|
||||||
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
|
github.com/molecule-man/go-brrr v1.1.0 // indirect
|
||||||
github.com/muesli/cancelreader v0.2.2 // indirect
|
github.com/muesli/cancelreader v0.2.2 // indirect
|
||||||
github.com/muesli/reflow v0.3.0 // indirect
|
|
||||||
github.com/muesli/termenv v0.16.0 // indirect
|
|
||||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||||
github.com/rivo/uniseg v0.4.7 // indirect
|
github.com/rivo/uniseg v0.4.7 // indirect
|
||||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
|
github.com/xo/terminfo v1.0.0 // indirect
|
||||||
github.com/yuin/goldmark v1.8.4 // indirect
|
github.com/yuin/goldmark v1.8.6 // indirect
|
||||||
github.com/yuin/goldmark-emoji v1.0.6 // indirect
|
github.com/yuin/goldmark-emoji v1.0.6 // indirect
|
||||||
golang.org/x/sys v0.47.0 // indirect
|
golang.org/x/sync v0.23.0 // indirect
|
||||||
golang.org/x/term v0.45.0 // indirect
|
golang.org/x/sys v0.48.0 // indirect
|
||||||
golang.org/x/text v0.40.0 // indirect
|
golang.org/x/text v0.42.0 // indirect
|
||||||
)
|
)
|
||||||
@@ -1,3 +1,11 @@
|
|||||||
|
charm.land/bubbles/v2 v2.2.1 h1:Fq1+qm5hV6GkvzLQDhCBpXXE5tLgvh1PRriCLwSvIQU=
|
||||||
|
charm.land/bubbles/v2 v2.2.1/go.mod h1:wdMgn+sje1KNXdwFizIWjbf328fIUBxqEmJ/vYPo8yc=
|
||||||
|
charm.land/bubbletea/v2 v2.0.10 h1:oolvo20VBpI0PfqE7iFjkZ1bx0WpmXGfnKz5Yldjq5o=
|
||||||
|
charm.land/bubbletea/v2 v2.0.10/go.mod h1:QOatcnhOjYIfxzUSTz6raF7Ex4R/rIuHa3SnBdCCpMc=
|
||||||
|
charm.land/glamour/v2 v2.0.1 h1:xl+r00A4aJWU0z8fgwKd9fQQ4rsphqGUzuEiXZP5n+c=
|
||||||
|
charm.land/glamour/v2 v2.0.1/go.mod h1:jo9z8XqVKPeEFMVdvCRLGk++RyJ3CdUwgNr7EvXLw3k=
|
||||||
|
charm.land/lipgloss/v2 v2.0.6 h1:EaGKeuA8FvF+v2BT5VmZd2LoYLaMZJXA5n34th8nCIQ=
|
||||||
|
charm.land/lipgloss/v2 v2.0.6/go.mod h1:ipDDJNSGa1hlwDtSfW1s2/xR8Vdhbut4PXh2zEKZd0Q=
|
||||||
github.com/Masterminds/semver/v3 v3.5.0 h1:kQceYJfbupGfZOKZQg0kou0DgAKhzDg2NZPAwZ/2OOE=
|
github.com/Masterminds/semver/v3 v3.5.0 h1:kQceYJfbupGfZOKZQg0kou0DgAKhzDg2NZPAwZ/2OOE=
|
||||||
github.com/Masterminds/semver/v3 v3.5.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
|
github.com/Masterminds/semver/v3 v3.5.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
|
||||||
github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0=
|
github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0=
|
||||||
@@ -6,101 +14,78 @@ github.com/alecthomas/chroma/v2 v2.27.0 h1:FodwmyOBgJULFYmDqibcp9pvfDLWdtPRh9v/r
|
|||||||
github.com/alecthomas/chroma/v2 v2.27.0/go.mod h1:NjJ3ciIgrqBNeIkWZ4e46nseoLDslxU1LmfCoL+wcY8=
|
github.com/alecthomas/chroma/v2 v2.27.0/go.mod h1:NjJ3ciIgrqBNeIkWZ4e46nseoLDslxU1LmfCoL+wcY8=
|
||||||
github.com/alecthomas/repr v0.5.2 h1:SU73FTI9D1P5UNtvseffFSGmdNci/O6RsqzeXJtP0Qs=
|
github.com/alecthomas/repr v0.5.2 h1:SU73FTI9D1P5UNtvseffFSGmdNci/O6RsqzeXJtP0Qs=
|
||||||
github.com/alecthomas/repr v0.5.2/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
|
github.com/alecthomas/repr v0.5.2/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
|
||||||
github.com/andybalholm/brotli v1.2.2 h1:HzTuoo2ErYQqf5qvcJInB8uvqSVxRttzkFexPWtnceM=
|
github.com/aymanbagabas/go-udiff v0.4.1 h1:OEIrQ8maEeDBXQDoGCbbTTXYJMYRCRO1fnodZ12Gv5o=
|
||||||
github.com/andybalholm/brotli v1.2.2/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY=
|
github.com/aymanbagabas/go-udiff v0.4.1/go.mod h1:0L9PGwj20lrtmEMeyw4WKJ/TMyDtvAoK9bf2u/mNo3w=
|
||||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
|
|
||||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
|
|
||||||
github.com/aymanbagabas/go-udiff v0.3.1 h1:LV+qyBQ2pqe0u42ZsUEtPiCaUoqgA9gYRDs3vj1nolY=
|
|
||||||
github.com/aymanbagabas/go-udiff v0.3.1/go.mod h1:G0fsKmG+P6ylD0r6N/KgQD/nWzgfnl8ZBcNLgcbrw8E=
|
|
||||||
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
|
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
|
||||||
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
|
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
|
||||||
github.com/brianvoe/gofakeit/v7 v7.15.0 h1:kGLYAWN8tnmxq2PelKVK6zwpM7kMxdz9SGPH31mFkNs=
|
github.com/brianvoe/gofakeit/v7 v7.17.1 h1:50FLBhTGVJQaj6ysRUu0it8wCdYO2uGM9VfuxI+csEc=
|
||||||
github.com/brianvoe/gofakeit/v7 v7.15.0/go.mod h1:QXuPeBw164PJCzCUZVmgpgHJ3Llj49jSLVkKPMtxtxA=
|
github.com/brianvoe/gofakeit/v7 v7.17.1/go.mod h1:QXuPeBw164PJCzCUZVmgpgHJ3Llj49jSLVkKPMtxtxA=
|
||||||
github.com/charmbracelet/bubbles v1.0.0 h1:12J8/ak/uCZEMQ6KU7pcfwceyjLlWsDLAxB5fXonfvc=
|
|
||||||
github.com/charmbracelet/bubbles v1.0.0/go.mod h1:9d/Zd5GdnauMI5ivUIVisuEm3ave1XwXtD1ckyV6r3E=
|
|
||||||
github.com/charmbracelet/bubbletea v1.3.10 h1:otUDHWMMzQSB0Pkc87rm691KZ3SWa4KUlvF9nRvCICw=
|
|
||||||
github.com/charmbracelet/bubbletea v1.3.10/go.mod h1:ORQfo0fk8U+po9VaNvnV95UPWA1BitP1E0N6xJPlHr4=
|
|
||||||
github.com/charmbracelet/colorprofile v0.4.3 h1:QPa1IWkYI+AOB+fE+mg/5/4HRMZcaXex9t5KX76i20Q=
|
github.com/charmbracelet/colorprofile v0.4.3 h1:QPa1IWkYI+AOB+fE+mg/5/4HRMZcaXex9t5KX76i20Q=
|
||||||
github.com/charmbracelet/colorprofile v0.4.3/go.mod h1:/zT4BhpD5aGFpqQQqw7a+VtHCzu+zrQtt1zhMt9mR4Q=
|
github.com/charmbracelet/colorprofile v0.4.3/go.mod h1:/zT4BhpD5aGFpqQQqw7a+VtHCzu+zrQtt1zhMt9mR4Q=
|
||||||
github.com/charmbracelet/glamour v1.0.0 h1:AWMLOVFHTsysl4WV8T8QgkQ0s/ZNZo7CiE4WKhk8l08=
|
|
||||||
github.com/charmbracelet/glamour v1.0.0/go.mod h1:DSdohgOBkMr2ZQNhw4LZxSGpx3SvpeujNoXrQyH2hxo=
|
|
||||||
github.com/charmbracelet/harmonica v0.2.0 h1:8NxJWRWg/bzKqqEaaeFNipOu77YR5t8aSwG4pgaUBiQ=
|
github.com/charmbracelet/harmonica v0.2.0 h1:8NxJWRWg/bzKqqEaaeFNipOu77YR5t8aSwG4pgaUBiQ=
|
||||||
github.com/charmbracelet/harmonica v0.2.0/go.mod h1:KSri/1RMQOZLbw7AHqgcBycp8pgJnQMYYT8QZRqZ1Ao=
|
github.com/charmbracelet/harmonica v0.2.0/go.mod h1:KSri/1RMQOZLbw7AHqgcBycp8pgJnQMYYT8QZRqZ1Ao=
|
||||||
github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834 h1:ZR7e0ro+SZZiIZD7msJyA+NjkCNNavuiPBLgerbOziE=
|
github.com/charmbracelet/ultraviolet v0.0.0-20260910203606-6c9e17dc7a16 h1:/hSCZO1puetbGd2JikHKN0nAcb2mFevzxJElFoduhaw=
|
||||||
github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834/go.mod h1:aKC/t2arECF6rNOnaKaVU6y4t4ZeHQzqfxedE/VkVhA=
|
github.com/charmbracelet/ultraviolet v0.0.0-20260910203606-6c9e17dc7a16/go.mod h1:JFvmQPZh3uAu7PpSZU91bcR0BrIy24HhW+0EsW1uGxE=
|
||||||
github.com/charmbracelet/x/ansi v0.11.7 h1:kzv1kJvjg2S3r9KHo8hDdHFQLEqn4RBCb39dAYC84jI=
|
github.com/charmbracelet/x/ansi v0.11.8 h1:JMFwp0CgDC2+jcOB162HH5k7I3FVbgFSMMYg7dSPBQQ=
|
||||||
github.com/charmbracelet/x/ansi v0.11.7/go.mod h1:9qGpnAVYz+8ACONkZBUWPtL7lulP9No6p1epAihUZwQ=
|
github.com/charmbracelet/x/ansi v0.11.8/go.mod h1:ZNN+3mXny/516oTQPLMPIBeSINvNJJQ8uQXDgbeJxY0=
|
||||||
github.com/charmbracelet/x/cellbuf v0.0.15 h1:ur3pZy0o6z/R7EylET877CBxaiE1Sp1GMxoFPAIztPI=
|
github.com/charmbracelet/x/exp/golden v0.0.0-20250806222409-83e3a29d542f h1:pk6gmGpCE7F3FcjaOEKYriCvpmIN4+6OS/RD0vm4uIA=
|
||||||
github.com/charmbracelet/x/cellbuf v0.0.15/go.mod h1:J1YVbR7MUuEGIFPCaaZ96KDl5NoS0DAWkskup+mOY+Q=
|
github.com/charmbracelet/x/exp/golden v0.0.0-20250806222409-83e3a29d542f/go.mod h1:IfZAMTHB6XkZSeXUqriemErjAWCCzT0LwjKFYCZyw0I=
|
||||||
github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91 h1:payRxjMjKgx2PaCWLZ4p3ro9y97+TVLZNaRZgJwSVDQ=
|
github.com/charmbracelet/x/exp/slice v0.0.0-20260906004030-3986e9119cf9 h1:zW96vcZ3zDetccerbN7sS/sCydOE/l/9S+C94pozsaU=
|
||||||
github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U=
|
github.com/charmbracelet/x/exp/slice v0.0.0-20260906004030-3986e9119cf9/go.mod h1:vqEfX6xzqW1pKKZUUiFOKg0OQ7bCh54Q2vR/tserrRA=
|
||||||
github.com/charmbracelet/x/exp/slice v0.0.0-20260726004341-482a56510f1b h1:VKASlRztdxT172siF4nJCwD1C+3mbveX41BiA96fIpA=
|
|
||||||
github.com/charmbracelet/x/exp/slice v0.0.0-20260726004341-482a56510f1b/go.mod h1:vqEfX6xzqW1pKKZUUiFOKg0OQ7bCh54Q2vR/tserrRA=
|
|
||||||
github.com/charmbracelet/x/term v0.2.2 h1:xVRT/S2ZcKdhhOuSP4t5cLi5o+JxklsoEObBSgfgZRk=
|
github.com/charmbracelet/x/term v0.2.2 h1:xVRT/S2ZcKdhhOuSP4t5cLi5o+JxklsoEObBSgfgZRk=
|
||||||
github.com/charmbracelet/x/term v0.2.2/go.mod h1:kF8CY5RddLWrsgVwpw4kAa6TESp6EB5y3uxGLeCqzAI=
|
github.com/charmbracelet/x/term v0.2.2/go.mod h1:kF8CY5RddLWrsgVwpw4kAa6TESp6EB5y3uxGLeCqzAI=
|
||||||
|
github.com/charmbracelet/x/termios v0.1.1 h1:o3Q2bT8eqzGnGPOYheoYS8eEleT5ZVNYNy8JawjaNZY=
|
||||||
|
github.com/charmbracelet/x/termios v0.1.1/go.mod h1:rB7fnv1TgOPOyyKRJ9o+AsTU/vK5WHJ2ivHeut/Pcwo=
|
||||||
|
github.com/charmbracelet/x/windows v0.2.2 h1:IofanmuvaxnKHuV04sC0eBy/smG6kIKrWG2/jYn2GuM=
|
||||||
|
github.com/charmbracelet/x/windows v0.2.2/go.mod h1:/8XtdKZzedat74NQFn0NGlGL4soHB0YQZrETF96h75k=
|
||||||
github.com/clipperhouse/displaywidth v0.11.0 h1:lBc6kY44VFw+TDx4I8opi/EtL9m20WSEFgwIwO+UVM8=
|
github.com/clipperhouse/displaywidth v0.11.0 h1:lBc6kY44VFw+TDx4I8opi/EtL9m20WSEFgwIwO+UVM8=
|
||||||
github.com/clipperhouse/displaywidth v0.11.0/go.mod h1:bkrFNkf81G8HyVqmKGxsPufD3JhNl3dSqnGhOoSD/o0=
|
github.com/clipperhouse/displaywidth v0.11.0/go.mod h1:bkrFNkf81G8HyVqmKGxsPufD3JhNl3dSqnGhOoSD/o0=
|
||||||
github.com/clipperhouse/uax29/v2 v2.7.0 h1:+gs4oBZ2gPfVrKPthwbMzWZDaAFPGYK72F0NJv2v7Vk=
|
github.com/clipperhouse/uax29/v2 v2.7.0 h1:+gs4oBZ2gPfVrKPthwbMzWZDaAFPGYK72F0NJv2v7Vk=
|
||||||
github.com/clipperhouse/uax29/v2 v2.7.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM=
|
github.com/clipperhouse/uax29/v2 v2.7.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM=
|
||||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
|
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
|
||||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/dlclark/regexp2/v2 v2.5.2 h1:HAsucWRhsqcDzl6Ua9aR8JwYOTzrZyPrF0/FNxJVAI0=
|
github.com/dlclark/regexp2/v2 v2.8.0 h1:CekDhPLGfm+GAJmPVFIG+5dqMIQPkyHJll7BbdneDfw=
|
||||||
github.com/dlclark/regexp2/v2 v2.5.2/go.mod h1:avUrQvPaLz2DrFNHJF0taWAFFX2C1GMSSoeiqFjcBmU=
|
github.com/dlclark/regexp2/v2 v2.8.0/go.mod h1:avUrQvPaLz2DrFNHJF0taWAFFX2C1GMSSoeiqFjcBmU=
|
||||||
github.com/dop251/goja v0.0.0-20260723142020-b4aef50fa347 h1:RZr+96+PKQjn444QL1K9MtncwJ/PwfE+3TJLCYJL8es=
|
github.com/dop251/goja v0.0.0-20260911104922-fabc3b8078ad h1:5gT9hQ9h8CplLZfAGgFMcoLqQS6I9T2sZwQOCXy8/3s=
|
||||||
github.com/dop251/goja v0.0.0-20260723142020-b4aef50fa347/go.mod h1:LiIEzozrcvNXorsG/3+ypGqdTUAqZryhzSsqi0oU/Qg=
|
github.com/dop251/goja v0.0.0-20260911104922-fabc3b8078ad/go.mod h1:u8yZRUavu+N4EnFFy6J5fVtjE7lEcZ2YyV2GcBXY9c8=
|
||||||
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
|
|
||||||
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
|
|
||||||
github.com/go-sourcemap/sourcemap v2.1.4+incompatible h1:a+iTbH5auLKxaNwQFg0B+TCYl6lbukKPc7b5x0n1s6Q=
|
github.com/go-sourcemap/sourcemap v2.1.4+incompatible h1:a+iTbH5auLKxaNwQFg0B+TCYl6lbukKPc7b5x0n1s6Q=
|
||||||
github.com/go-sourcemap/sourcemap v2.1.4+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg=
|
github.com/go-sourcemap/sourcemap v2.1.4+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg=
|
||||||
github.com/goccy/go-yaml v1.19.2 h1:PmFC1S6h8ljIz6gMRBopkjP1TVT7xuwrButHID66PoM=
|
github.com/goccy/go-yaml v1.19.2 h1:PmFC1S6h8ljIz6gMRBopkjP1TVT7xuwrButHID66PoM=
|
||||||
github.com/goccy/go-yaml v1.19.2/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
|
github.com/goccy/go-yaml v1.19.2/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
|
||||||
github.com/google/pprof v0.0.0-20260709232956-b9395ee17fa0 h1:du0WGc8xSKq/++e0cglxhS/mXVqsR7+c7jLEi5Vqduw=
|
github.com/google/pprof v0.0.0-20260906184651-6331bc6350fe h1:QAinXoAFJdGQYztXn3VpFey7KCwpedbZ/EkzbplQ0cY=
|
||||||
github.com/google/pprof v0.0.0-20260709232956-b9395ee17fa0/go.mod h1:MxpfABSjhmINe3F1It9d+8exIHFvUqtLIRCdOGNXqiI=
|
github.com/google/pprof v0.0.0-20260906184651-6331bc6350fe/go.mod h1:jl5iWTm0/hd5PjEYEOuwAJ57L/CibdZfrqZ5XA5GrCk=
|
||||||
github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8=
|
github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8=
|
||||||
github.com/gorilla/css v1.0.1/go.mod h1:BvnYkspnSzMmwRK+b8/xgNPLiIuNZr6vbZBTPQ2A3b0=
|
github.com/gorilla/css v1.0.1/go.mod h1:BvnYkspnSzMmwRK+b8/xgNPLiIuNZr6vbZBTPQ2A3b0=
|
||||||
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
|
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
|
||||||
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
|
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
|
||||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||||
github.com/klauspost/compress v1.19.1 h1:VsB4HPswih7mmZ8WleSFQ75c/Ui1M4trX5oAsJnhSlk=
|
github.com/klauspost/compress v1.20.0 h1:a3C1ke2ohxFymNlb2HWAHjDeKCI90scRskErZkR0ezA=
|
||||||
github.com/klauspost/compress v1.19.1/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ=
|
github.com/klauspost/compress v1.20.0/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI=
|
||||||
github.com/lucasb-eyer/go-colorful v1.4.0 h1:UtrWVfLdarDgc44HcS7pYloGHJUjHV/4FwW4TvVgFr4=
|
github.com/lucasb-eyer/go-colorful v1.4.1 h1:1EO+WB73+EH8EVbzlrG3KLAfEypQWVHIBqlTf+2hNss=
|
||||||
github.com/lucasb-eyer/go-colorful v1.4.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
github.com/lucasb-eyer/go-colorful v1.4.1/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||||
github.com/mattn/go-isatty v0.0.24 h1:tGZZoVgT/KiqK1c8ocVLeDS8BSWMRd47J3Lbz7vsReI=
|
github.com/mattn/go-runewidth v0.0.30 h1:+KUuiDA4fF0R1p5FeueHefjDm+GIM+kWfFnDjybOPgk=
|
||||||
github.com/mattn/go-isatty v0.0.24/go.mod h1:nMCL3Zebbrt45jsMDgnfIwz6ydEQApk5oEI3HqDio6A=
|
github.com/mattn/go-runewidth v0.0.30/go.mod h1:3qAiGCV4Koz/yuveO58qUefmUTRm8r0IGEXZ9jeHp/8=
|
||||||
github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4=
|
|
||||||
github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88=
|
|
||||||
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
|
|
||||||
github.com/mattn/go-runewidth v0.0.27 h1:Feg/Oou5zI/wnpgDF6omIU0OokC9GxLC/WRknhVlIR0=
|
|
||||||
github.com/mattn/go-runewidth v0.0.27/go.mod h1:3qAiGCV4Koz/yuveO58qUefmUTRm8r0IGEXZ9jeHp/8=
|
|
||||||
github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk=
|
github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk=
|
||||||
github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA=
|
github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA=
|
||||||
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI=
|
github.com/molecule-man/go-brrr v1.1.0 h1:rLBGSXA393y+5ttCBLkW34CHESop5tahrOFxVv/XDEU=
|
||||||
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo=
|
github.com/molecule-man/go-brrr v1.1.0/go.mod h1:7ybW6/7gA3oKY45jOfVNjSJDtrr6ea4tzbsTkjmQDC4=
|
||||||
github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=
|
github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=
|
||||||
github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
|
github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
|
||||||
github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
|
|
||||||
github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
|
|
||||||
github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc=
|
|
||||||
github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
|
|
||||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
|
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
|
||||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
|
||||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
|
||||||
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||||
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||||
github.com/valyala/fasthttp v1.72.0 h1:R7kYdoWhn1ye1fVpP+cDHDJwYm3NkwLliwgzJ/Abg7M=
|
github.com/valyala/fasthttp v1.74.0 h1:wMS9fnO2QTALozYx5pId2Vi7ZwU/epUkY8i/KPWCHoU=
|
||||||
github.com/valyala/fasthttp v1.72.0/go.mod h1:zsbLTYqcpIktdQytlVBwIjY9La5d6bs990nBxWg8efk=
|
github.com/valyala/fasthttp v1.74.0/go.mod h1:3ARmLamUcw7ElxVtC8PXaGzQ6VEuvnetlkrwIklQBSE=
|
||||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
|
github.com/xo/terminfo v1.0.0 h1:2ZpYzqWzyyytjk3TP6aJVDhkMAkc99/1xKQdA3TDTBY=
|
||||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
|
github.com/xo/terminfo v1.0.0/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
|
||||||
github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU=
|
github.com/yuin/goldmark v1.8.6 h1:d0VcaP1sx9GkFVkoW+KtggpGi2KZ965i14b0+bDQST4=
|
||||||
github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
|
github.com/yuin/goldmark v1.8.6/go.mod h1:ip/1k0VRfGynBgxOz0yCqHrbZXhcjxyuS66Brc7iBKg=
|
||||||
github.com/yuin/goldmark v1.8.4 h1:oat/nd3U6NeQqFEL3xpEJq7d7c86NI+DbSNGAs4xnjA=
|
|
||||||
github.com/yuin/goldmark v1.8.4/go.mod h1:ip/1k0VRfGynBgxOz0yCqHrbZXhcjxyuS66Brc7iBKg=
|
|
||||||
github.com/yuin/goldmark-emoji v1.0.6 h1:QWfF2FYaXwL74tfGOW5izeiZepUDroDJfWubQI9HTHs=
|
github.com/yuin/goldmark-emoji v1.0.6 h1:QWfF2FYaXwL74tfGOW5izeiZepUDroDJfWubQI9HTHs=
|
||||||
github.com/yuin/goldmark-emoji v1.0.6/go.mod h1:ukxJDKFpdFb5x0a5HqbdlcKtebh086iJpI31LTKmWuA=
|
github.com/yuin/goldmark-emoji v1.0.6/go.mod h1:ukxJDKFpdFb5x0a5HqbdlcKtebh086iJpI31LTKmWuA=
|
||||||
github.com/yuin/gopher-lua v1.1.2 h1:yF/FjE3hD65tBbt0VXLE13HWS9h34fdzJmrWRXwobGA=
|
github.com/yuin/gopher-lua v1.1.2 h1:yF/FjE3hD65tBbt0VXLE13HWS9h34fdzJmrWRXwobGA=
|
||||||
@@ -111,14 +96,15 @@ go.yaml.in/yaml/v4 v4.0.0-rc.6 h1:1h7H1ohdUh93/FyE4YaDa1Zh64K6VVbjF4K6WUxMtH4=
|
|||||||
go.yaml.in/yaml/v4 v4.0.0-rc.6/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0=
|
go.yaml.in/yaml/v4 v4.0.0-rc.6/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0=
|
||||||
golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
|
golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
|
||||||
golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
|
golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
|
||||||
golang.org/x/net v0.57.0 h1:K5+3DljvIuDG9/Jv9rvyMywYNFCQ9RSUY6OOTTkT+tE=
|
golang.org/x/net v0.59.0 h1:5zfYln+w5XCxwrnMMJPufRgNoXEaGxl0wo5GqPXyues=
|
||||||
golang.org/x/net v0.57.0/go.mod h1:KpXc8iv+r3XplLAG/f7Jsf9RPszJzdR0f58q9vGOuEU=
|
golang.org/x/net v0.59.0/go.mod h1:2DA/G1UfVbCpQPeWTmMPGY7Cs2PkBkwu743bVX5PIVg=
|
||||||
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sync v0.23.0 h1:KameEIfc1IkluZyXWLn39Wd4tURc6GbCiISGiZm2bQk=
|
||||||
golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
|
golang.org/x/sync v0.23.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
|
||||||
golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
golang.org/x/sys v0.48.0 h1:bbX/i/6MgT9BVLM9RT1thmxL04yeTAhbEz4SyadbXoo=
|
||||||
golang.org/x/term v0.45.0 h1:NwWyBmoJCbfTHpxrWoZ9C6/VxOf7ic219I8xZZFdrf0=
|
golang.org/x/sys v0.48.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||||
golang.org/x/term v0.45.0/go.mod h1:9aqxs0blBcrm/n0L9QW0aRVD+ktan8ssZromtqJC43w=
|
golang.org/x/text v0.42.0 h1:JbOZXgfeCPU9gacVtYliJqOhD+zhrEqK4LfdpmlUZqI=
|
||||||
golang.org/x/text v0.40.0 h1:Ub2Z6/xjgF1WrYQz2nuITOEegKFtiIy+rieRJ5lHZKs=
|
golang.org/x/text v0.42.0/go.mod h1:ojzP1Z+2QtioaF8DTtO8K5q7JWVVYwZKenzujK0Zd0E=
|
||||||
golang.org/x/text v0.40.0/go.mod h1:hpnzDAfGV753zIKo+wk3u1bVKCGPbrnF7+7LBF/UHVY=
|
golang.org/x/tools v0.49.0 h1:3NI7VXzL9+1WZD52Dx2ttoPwD5DWrFGpl9mFZDlmisI=
|
||||||
|
golang.org/x/tools v0.49.0/go.mod h1:SJNXV9DBKT0UbdttsQjbfJlAE/q+y36++zo3uL3N0Oo=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
+40
-33
@@ -12,12 +12,11 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/charmbracelet/bubbles/viewport"
|
"charm.land/bubbles/v2/viewport"
|
||||||
tea "github.com/charmbracelet/bubbletea"
|
tea "charm.land/bubbletea/v2"
|
||||||
"github.com/charmbracelet/glamour"
|
"charm.land/glamour/v2"
|
||||||
"github.com/charmbracelet/glamour/styles"
|
"charm.land/glamour/v2/styles"
|
||||||
"github.com/charmbracelet/lipgloss"
|
"charm.land/lipgloss/v2"
|
||||||
"github.com/charmbracelet/x/term"
|
|
||||||
"go.aykhans.me/sarin/internal/sarin"
|
"go.aykhans.me/sarin/internal/sarin"
|
||||||
"go.aykhans.me/sarin/internal/script"
|
"go.aykhans.me/sarin/internal/script"
|
||||||
"go.aykhans.me/sarin/internal/types"
|
"go.aykhans.me/sarin/internal/types"
|
||||||
@@ -249,12 +248,12 @@ func (config Config) MarshalYAML() (any, error) {
|
|||||||
func (config Config) Print() bool {
|
func (config Config) Print() bool {
|
||||||
configYAML, err := yaml.Marshal(config)
|
configYAML, err := yaml.Marshal(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintln(os.Stderr, StyleRed.Render("Error marshaling config to yaml: "+err.Error()))
|
fmt.Fprint(os.Stderr, lipgloss.Sprintln(StyleRed.Render("Error marshaling config to yaml: "+err.Error())))
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pipe mode: output raw content directly
|
// Pipe mode: output raw content directly
|
||||||
if !term.IsTerminal(os.Stdout.Fd()) {
|
if !sarin.IsInteractiveTerminal(os.Stdout.Fd()) {
|
||||||
fmt.Println(string(configYAML))
|
fmt.Println(string(configYAML))
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
@@ -268,25 +267,23 @@ func (config Config) Print() bool {
|
|||||||
glamour.WithWordWrap(0),
|
glamour.WithWordWrap(0),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintln(os.Stderr, StyleRed.Render(err.Error()))
|
fmt.Fprint(os.Stderr, lipgloss.Sprintln(StyleRed.Render(err.Error())))
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
content, err := renderer.Render("```yaml\n" + string(configYAML) + "```")
|
content, err := renderer.Render("```yaml\n" + string(configYAML) + "```")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintln(os.Stderr, StyleRed.Render(err.Error()))
|
fmt.Fprint(os.Stderr, lipgloss.Sprintln(StyleRed.Render(err.Error())))
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
p := tea.NewProgram(
|
p := tea.NewProgram(
|
||||||
printConfigModel{content: strings.Trim(content, "\n"), rawContent: configYAML},
|
printConfigModel{content: strings.Trim(content, "\n"), rawContent: configYAML},
|
||||||
tea.WithAltScreen(),
|
|
||||||
tea.WithMouseCellMotion(),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
m, err := p.Run()
|
m, err := p.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintln(os.Stderr, StyleRed.Render(err.Error()))
|
fmt.Fprint(os.Stderr, lipgloss.Sprintln(StyleRed.Render(err.Error())))
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -616,11 +613,11 @@ func ReadAllConfigs() *Config {
|
|||||||
_ = utilsErr.MustHandle(err,
|
_ = utilsErr.MustHandle(err,
|
||||||
utilsErr.OnType(func(err types.CLIUnexpectedArgsError) error {
|
utilsErr.OnType(func(err types.CLIUnexpectedArgsError) error {
|
||||||
cliParser.PrintHelp()
|
cliParser.PrintHelp()
|
||||||
fmt.Fprintln(os.Stderr,
|
fmt.Fprint(os.Stderr, lipgloss.Sprintln(
|
||||||
StyleYellow.Render(
|
StyleYellow.Render(
|
||||||
"\nUnexpected CLI arguments provided: ",
|
"\nUnexpected CLI arguments provided: ",
|
||||||
)+strings.Join(err.Args, ", "),
|
)+strings.Join(err.Args, ", "),
|
||||||
)
|
))
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
return nil
|
return nil
|
||||||
}),
|
}),
|
||||||
@@ -638,20 +635,20 @@ func ReadAllConfigs() *Config {
|
|||||||
_ = utilsErr.MustHandle(err,
|
_ = utilsErr.MustHandle(err,
|
||||||
utilsErr.OnType(func(err types.ConfigFileReadError) error {
|
utilsErr.OnType(func(err types.ConfigFileReadError) error {
|
||||||
cliParser.PrintHelp()
|
cliParser.PrintHelp()
|
||||||
fmt.Fprintln(os.Stderr,
|
fmt.Fprint(os.Stderr, lipgloss.Sprintln(
|
||||||
StyleYellow.Render(
|
StyleYellow.Render(
|
||||||
fmt.Sprintf("\nFailed to read config file (%s): ", configFile.Path())+err.Error(),
|
fmt.Sprintf("\nFailed to read config file (%s): ", configFile.Path())+err.Error(),
|
||||||
),
|
),
|
||||||
)
|
))
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
return nil
|
return nil
|
||||||
}),
|
}),
|
||||||
utilsErr.OnType(func(err types.UnmarshalError) error {
|
utilsErr.OnType(func(err types.UnmarshalError) error {
|
||||||
fmt.Fprintln(os.Stderr,
|
fmt.Fprint(os.Stderr, lipgloss.Sprintln(
|
||||||
StyleYellow.Render(
|
StyleYellow.Render(
|
||||||
fmt.Sprintf("\nFailed to parse config file (%s): ", configFile.Path())+err.Error(),
|
fmt.Sprintf("\nFailed to parse config file (%s): ", configFile.Path())+err.Error(),
|
||||||
),
|
),
|
||||||
)
|
))
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
return nil
|
return nil
|
||||||
}),
|
}),
|
||||||
@@ -754,13 +751,13 @@ func validateScriptSource(script string) error {
|
|||||||
func printParseErrors(parserName string, errors ...types.FieldParseError) {
|
func printParseErrors(parserName string, errors ...types.FieldParseError) {
|
||||||
for _, fieldErr := range errors {
|
for _, fieldErr := range errors {
|
||||||
if fieldErr.Value == "" {
|
if fieldErr.Value == "" {
|
||||||
fmt.Fprintln(os.Stderr,
|
fmt.Fprint(os.Stderr, lipgloss.Sprintln(
|
||||||
StyleYellow.Render(fmt.Sprintf("[%s] Field '%s': ", parserName, fieldErr.Field))+fieldErr.Err.Error(),
|
StyleYellow.Render(fmt.Sprintf("[%s] Field '%s': ", parserName, fieldErr.Field))+fieldErr.Err.Error(),
|
||||||
)
|
))
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprintln(os.Stderr,
|
fmt.Fprint(os.Stderr, lipgloss.Sprintln(
|
||||||
StyleYellow.Render(fmt.Sprintf("[%s] Field '%s' (%s): ", parserName, fieldErr.Field, fieldErr.Value))+fieldErr.Err.Error(),
|
StyleYellow.Render(fmt.Sprintf("[%s] Field '%s' (%s): ", parserName, fieldErr.Field, fieldErr.Value))+fieldErr.Err.Error(),
|
||||||
)
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -801,7 +798,7 @@ func (m printConfigModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
var cmd tea.Cmd
|
var cmd tea.Cmd
|
||||||
|
|
||||||
switch msg := msg.(type) {
|
switch msg := msg.(type) {
|
||||||
case tea.KeyMsg:
|
case tea.KeyPressMsg:
|
||||||
switch msg.String() {
|
switch msg.String() {
|
||||||
case "ctrl+c", "esc":
|
case "ctrl+c", "esc":
|
||||||
return m, tea.Quit
|
return m, tea.Quit
|
||||||
@@ -824,13 +821,22 @@ func (m printConfigModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
return m, cmd
|
return m, cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m printConfigModel) View() string {
|
func (m printConfigModel) View() tea.View {
|
||||||
|
// AltScreen and MouseMode were program options in bubbletea v1; in v2 they
|
||||||
|
// are view properties, so every return path has to declare them.
|
||||||
|
newView := func(s string) tea.View {
|
||||||
|
v := tea.NewView(s)
|
||||||
|
v.AltScreen = true
|
||||||
|
v.MouseMode = tea.MouseModeCellMotion
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
if !m.ready {
|
if !m.ready {
|
||||||
return "\n Initializing..."
|
return newView("\n Initializing...")
|
||||||
}
|
}
|
||||||
|
|
||||||
content := lipgloss.JoinHorizontal(lipgloss.Top, m.viewport.View(), m.scrollbar())
|
content := lipgloss.JoinHorizontal(lipgloss.Top, m.viewport.View(), m.scrollbar())
|
||||||
return fmt.Sprintf("%s\n%s\n%s", m.headerView(), content, m.footerView())
|
return newView(fmt.Sprintf("%s\n%s\n%s", m.headerView(), content, m.footerView()))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *printConfigModel) saveContent() (printConfigModel, tea.Cmd) {
|
func (m *printConfigModel) saveContent() (printConfigModel, tea.Cmd) {
|
||||||
@@ -850,12 +856,13 @@ func (m *printConfigModel) handleResize(msg tea.WindowSizeMsg) {
|
|||||||
width := msg.Width - scrollbarWidth
|
width := msg.Width - scrollbarWidth
|
||||||
|
|
||||||
if !m.ready {
|
if !m.ready {
|
||||||
m.viewport = viewport.New(width, height)
|
m.viewport = viewport.New(viewport.WithWidth(width), viewport.WithHeight(height))
|
||||||
|
m.viewport.SetHorizontalStep(0)
|
||||||
m.viewport.SetContent(m.contentWithLineNumbers())
|
m.viewport.SetContent(m.contentWithLineNumbers())
|
||||||
m.ready = true
|
m.ready = true
|
||||||
} else {
|
} else {
|
||||||
m.viewport.Width = width
|
m.viewport.SetWidth(width)
|
||||||
m.viewport.Height = height
|
m.viewport.SetHeight(height)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -870,12 +877,12 @@ func (m printConfigModel) headerView() string {
|
|||||||
printConfigKeyStyle.Render("ESC") + printConfigDescStyle.Render(" exit")
|
printConfigKeyStyle.Render("ESC") + printConfigDescStyle.Render(" exit")
|
||||||
title = printConfigHelpStyle.Render(help)
|
title = printConfigHelpStyle.Render(help)
|
||||||
}
|
}
|
||||||
line := strings.Repeat("─", max(0, m.viewport.Width+scrollbarWidth-lipgloss.Width(title)))
|
line := strings.Repeat("─", max(0, m.viewport.Width()+scrollbarWidth-lipgloss.Width(title)))
|
||||||
return lipgloss.JoinHorizontal(lipgloss.Center, title, line)
|
return lipgloss.JoinHorizontal(lipgloss.Center, title, line)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m printConfigModel) footerView() string {
|
func (m printConfigModel) footerView() string {
|
||||||
return strings.Repeat("─", m.viewport.Width+scrollbarWidth)
|
return strings.Repeat("─", m.viewport.Width()+scrollbarWidth)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m printConfigModel) contentWithLineNumbers() string {
|
func (m printConfigModel) contentWithLineNumbers() string {
|
||||||
@@ -897,7 +904,7 @@ func (m printConfigModel) contentWithLineNumbers() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m printConfigModel) scrollbar() string {
|
func (m printConfigModel) scrollbar() string {
|
||||||
height := m.viewport.Height
|
height := m.viewport.Height()
|
||||||
trackHeight := height - scrollbarBottomSpace
|
trackHeight := height - scrollbarBottomSpace
|
||||||
totalLines := m.viewport.TotalLineCount()
|
totalLines := m.viewport.TotalLineCount()
|
||||||
|
|
||||||
|
|||||||
+85
-33
@@ -56,9 +56,9 @@ func NewRequestGenerator(
|
|||||||
|
|
||||||
pathGenerator, isPathGeneratorDynamic := createTemplateFunc(requestURL.Path, lazyTemplateRoot)
|
pathGenerator, isPathGeneratorDynamic := createTemplateFunc(requestURL.Path, lazyTemplateRoot)
|
||||||
methodGenerator, isMethodGeneratorDynamic := NewMethodGeneratorFunc(localRand, methods, lazyTemplateRoot)
|
methodGenerator, isMethodGeneratorDynamic := NewMethodGeneratorFunc(localRand, methods, lazyTemplateRoot)
|
||||||
paramsGenerator, isParamsGeneratorDynamic := NewParamsGeneratorFunc(localRand, params, lazyTemplateRoot)
|
paramsGenerator, isParamsGeneratorDynamic, paramKeysAreStatic := NewParamsGeneratorFunc(localRand, params, lazyTemplateRoot)
|
||||||
headersGenerator, isHeadersGeneratorDynamic := NewHeadersGeneratorFunc(localRand, headers, lazyTemplateRoot)
|
headersGenerator, isHeadersGeneratorDynamic, headerKeysAreStatic := NewHeadersGeneratorFunc(localRand, headers, lazyTemplateRoot)
|
||||||
cookiesGenerator, isCookiesGeneratorDynamic := NewCookiesGeneratorFunc(localRand, cookies, lazyTemplateRoot)
|
cookiesGenerator, isCookiesGeneratorDynamic, cookieKeysAreStatic := NewCookiesGeneratorFunc(localRand, cookies, lazyTemplateRoot)
|
||||||
|
|
||||||
bodyTemplateFuncMapData := &BodyTemplateFuncMapData{}
|
bodyTemplateFuncMapData := &BodyTemplateFuncMapData{}
|
||||||
var bodyTemplateRoot *template.Template
|
var bodyTemplateRoot *template.Template
|
||||||
@@ -83,13 +83,26 @@ func NewRequestGenerator(
|
|||||||
Cookies: make(map[string][]string),
|
Cookies: make(map[string][]string),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When a map's key set is fixed, every request refills exactly the same keys, so
|
||||||
|
// the value slices can be truncated and reused instead of being reallocated after
|
||||||
|
// a clear(). Scripts are excluded: they may swap the maps out or add keys of their
|
||||||
|
// own, and they would observe a leftover empty slice where a key used to be absent.
|
||||||
|
reuseParamSlices := paramKeysAreStatic && !hasScripts
|
||||||
|
reuseHeaderSlices := headerKeysAreStatic && !hasScripts
|
||||||
|
reuseCookieSlices := cookieKeysAreStatic && !hasScripts
|
||||||
|
|
||||||
var (
|
var (
|
||||||
data valuesData
|
data valuesData
|
||||||
path string
|
path string
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
return func(req *fasthttp.Request) error {
|
return func(req *fasthttp.Request) error {
|
||||||
resetRequestData(reqData)
|
resetStringSliceMap(reqData.Headers, reuseHeaderSlices)
|
||||||
|
resetStringSliceMap(reqData.Params, reuseParamSlices)
|
||||||
|
resetStringSliceMap(reqData.Cookies, reuseCookieSlices)
|
||||||
|
reqData.Method = ""
|
||||||
|
reqData.Path = ""
|
||||||
|
reqData.Body = ""
|
||||||
|
|
||||||
data, err = valuesGenerator()
|
data, err = valuesGenerator()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -143,20 +156,24 @@ func NewRequestGenerator(
|
|||||||
hasScripts
|
hasScripts
|
||||||
}
|
}
|
||||||
|
|
||||||
func resetRequestData(reqData *script.RequestData) {
|
// resetStringSliceMap empties m for the next render. With reuse it truncates the
|
||||||
reqData.Method = ""
|
// value slices in place so the following appends land in the existing backing
|
||||||
reqData.Path = ""
|
// arrays, without it the map is cleared so no stale key can survive.
|
||||||
reqData.Body = ""
|
func resetStringSliceMap(m map[string][]string, reuse bool) {
|
||||||
clear(reqData.Headers)
|
if !reuse {
|
||||||
clear(reqData.Params)
|
clear(m)
|
||||||
clear(reqData.Cookies)
|
return
|
||||||
|
}
|
||||||
|
for k, v := range m {
|
||||||
|
m[k] = v[:0]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func applyRequestDataToFastHTTP(reqData *script.RequestData, req *fasthttp.Request, host, scheme string) {
|
func applyRequestDataToFastHTTP(reqData *script.RequestData, req *fasthttp.Request, host, scheme string) {
|
||||||
req.Header.SetHost(host)
|
req.Header.SetHost(host)
|
||||||
req.SetRequestURI(reqData.Path)
|
req.SetRequestURI(reqData.Path)
|
||||||
req.Header.SetMethod(reqData.Method)
|
req.Header.SetMethod(reqData.Method)
|
||||||
req.SetBody([]byte(reqData.Body))
|
req.SetBodyString(reqData.Body)
|
||||||
|
|
||||||
for k, values := range reqData.Headers {
|
for k, values := range reqData.Headers {
|
||||||
for _, v := range values {
|
for _, v := range values {
|
||||||
@@ -164,20 +181,28 @@ func applyRequestDataToFastHTTP(reqData *script.RequestData, req *fasthttp.Reque
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for k, values := range reqData.Params {
|
if len(reqData.Params) > 0 {
|
||||||
for _, v := range values {
|
args := req.URI().QueryArgs()
|
||||||
req.URI().QueryArgs().Add(k, v)
|
for k, values := range reqData.Params {
|
||||||
|
for _, v := range values {
|
||||||
|
args.Add(k, v)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(reqData.Cookies) > 0 {
|
if len(reqData.Cookies) > 0 {
|
||||||
cookieStrings := make([]string, 0, len(reqData.Cookies))
|
var sb strings.Builder
|
||||||
for k, values := range reqData.Cookies {
|
for k, values := range reqData.Cookies {
|
||||||
for _, v := range values {
|
for _, v := range values {
|
||||||
cookieStrings = append(cookieStrings, k+"="+v)
|
if sb.Len() > 0 {
|
||||||
|
sb.WriteString("; ")
|
||||||
|
}
|
||||||
|
sb.WriteString(k)
|
||||||
|
sb.WriteByte('=')
|
||||||
|
sb.WriteString(v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
req.Header.Add("Cookie", strings.Join(cookieStrings, "; "))
|
req.Header.Add("Cookie", sb.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
if scheme == "https" {
|
if scheme == "https" {
|
||||||
@@ -221,8 +246,8 @@ func NewBodyGeneratorFunc(localRand *rand.Rand, bodies []string, lazyRoot func()
|
|||||||
}, isDynamic
|
}, isDynamic
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewParamsGeneratorFunc(localRand *rand.Rand, params types.Params, lazyRoot func() *template.Template) (requestDataGenerator, bool) {
|
func NewParamsGeneratorFunc(localRand *rand.Rand, params types.Params, lazyRoot func() *template.Template) (requestDataGenerator, bool, bool) {
|
||||||
generators, isDynamic := buildKeyValueGenerators(localRand, params, lazyRoot)
|
generators, isDynamic, keysAreStatic := buildKeyValueGenerators(localRand, params, lazyRoot)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
key, value string
|
key, value string
|
||||||
@@ -243,11 +268,11 @@ func NewParamsGeneratorFunc(localRand *rand.Rand, params types.Params, lazyRoot
|
|||||||
reqData.Params[key] = append(reqData.Params[key], value)
|
reqData.Params[key] = append(reqData.Params[key], value)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}, isDynamic
|
}, isDynamic, keysAreStatic
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewHeadersGeneratorFunc(localRand *rand.Rand, headers types.Headers, lazyRoot func() *template.Template) (requestDataGenerator, bool) {
|
func NewHeadersGeneratorFunc(localRand *rand.Rand, headers types.Headers, lazyRoot func() *template.Template) (requestDataGenerator, bool, bool) {
|
||||||
generators, isDynamic := buildKeyValueGenerators(localRand, headers, lazyRoot)
|
generators, isDynamic, keysAreStatic := buildKeyValueGenerators(localRand, headers, lazyRoot)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
key, value string
|
key, value string
|
||||||
@@ -268,11 +293,11 @@ func NewHeadersGeneratorFunc(localRand *rand.Rand, headers types.Headers, lazyRo
|
|||||||
reqData.Headers[key] = append(reqData.Headers[key], value)
|
reqData.Headers[key] = append(reqData.Headers[key], value)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}, isDynamic
|
}, isDynamic, keysAreStatic
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCookiesGeneratorFunc(localRand *rand.Rand, cookies types.Cookies, lazyRoot func() *template.Template) (requestDataGenerator, bool) {
|
func NewCookiesGeneratorFunc(localRand *rand.Rand, cookies types.Cookies, lazyRoot func() *template.Template) (requestDataGenerator, bool, bool) {
|
||||||
generators, isDynamic := buildKeyValueGenerators(localRand, cookies, lazyRoot)
|
generators, isDynamic, keysAreStatic := buildKeyValueGenerators(localRand, cookies, lazyRoot)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
key, value string
|
key, value string
|
||||||
@@ -293,14 +318,26 @@ func NewCookiesGeneratorFunc(localRand *rand.Rand, cookies types.Cookies, lazyRo
|
|||||||
reqData.Cookies[key] = append(reqData.Cookies[key], value)
|
reqData.Cookies[key] = append(reqData.Cookies[key], value)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}, isDynamic
|
}, isDynamic, keysAreStatic
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewValuesGeneratorFunc(values []string, lazyRoot func() *template.Template) func() (valuesData, error) {
|
func NewValuesGeneratorFunc(values []string, lazyRoot func() *template.Template) func() (valuesData, error) {
|
||||||
|
// No values configured: hand back one shared empty map instead of allocating a
|
||||||
|
// fresh one for every request. Nothing ever writes to it.
|
||||||
|
if len(values) == 0 {
|
||||||
|
empty := valuesData{Values: map[string]string{}}
|
||||||
|
return func() (valuesData, error) { return empty, nil }
|
||||||
|
}
|
||||||
|
|
||||||
generators := make([]func(_ any) (string, error), len(values))
|
generators := make([]func(_ any) (string, error), len(values))
|
||||||
|
|
||||||
|
isDynamic := false
|
||||||
for i, v := range values {
|
for i, v := range values {
|
||||||
generators[i], _ = createTemplateFunc(v, lazyRoot)
|
var valueIsDynamic bool
|
||||||
|
generators[i], valueIsDynamic = createTemplateFunc(v, lazyRoot)
|
||||||
|
if valueIsDynamic {
|
||||||
|
isDynamic = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -308,7 +345,7 @@ func NewValuesGeneratorFunc(values []string, lazyRoot func() *template.Template)
|
|||||||
data map[string]string
|
data map[string]string
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
return func() (valuesData, error) {
|
generate := func() (valuesData, error) {
|
||||||
result := make(map[string]string)
|
result := make(map[string]string)
|
||||||
for _, generator := range generators {
|
for _, generator := range generators {
|
||||||
rendered, err = generator(nil)
|
rendered, err = generator(nil)
|
||||||
@@ -326,6 +363,15 @@ func NewValuesGeneratorFunc(values []string, lazyRoot func() *template.Template)
|
|||||||
|
|
||||||
return valuesData{Values: result}, nil
|
return valuesData{Values: result}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Every value is a literal, so the parsed result is identical on every request:
|
||||||
|
// render and parse once instead of re-running godotenv per request.
|
||||||
|
if !isDynamic {
|
||||||
|
staticResult, staticErr := generate()
|
||||||
|
return func() (valuesData, error) { return staticResult, staticErr }
|
||||||
|
}
|
||||||
|
|
||||||
|
return generate
|
||||||
}
|
}
|
||||||
|
|
||||||
func createTemplateFunc(value string, lazyRoot func() *template.Template) (func(data any) (string, error), bool) {
|
func createTemplateFunc(value string, lazyRoot func() *template.Template) (func(data any) (string, error), bool) {
|
||||||
@@ -335,15 +381,19 @@ func createTemplateFunc(value string, lazyRoot func() *template.Template) (func(
|
|||||||
|
|
||||||
tmpl, err := lazyRoot().New("").Parse(value)
|
tmpl, err := lazyRoot().New("").Parse(value)
|
||||||
if err == nil && hasTemplateActions(tmpl) {
|
if err == nil && hasTemplateActions(tmpl) {
|
||||||
var err error
|
var (
|
||||||
|
buf bytes.Buffer
|
||||||
|
err error
|
||||||
|
)
|
||||||
return func(data any) (string, error) {
|
return func(data any) (string, error) {
|
||||||
var buf bytes.Buffer
|
buf.Reset()
|
||||||
if err = tmpl.Execute(&buf, data); err != nil {
|
if err = tmpl.Execute(&buf, data); err != nil {
|
||||||
return "", types.NewTemplateRenderError(err)
|
return "", types.NewTemplateRenderError(err)
|
||||||
}
|
}
|
||||||
return buf.String(), nil
|
return buf.String(), nil
|
||||||
}, true
|
}, true
|
||||||
}
|
}
|
||||||
|
|
||||||
return func(_ any) (string, error) { return value, nil }, false
|
return func(_ any) (string, error) { return value, nil }, false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -360,8 +410,9 @@ func buildKeyValueGenerators[T keyValueItem](
|
|||||||
localRand *rand.Rand,
|
localRand *rand.Rand,
|
||||||
items []T,
|
items []T,
|
||||||
lazyRoot func() *template.Template,
|
lazyRoot func() *template.Template,
|
||||||
) ([]keyValueGenerator, bool) {
|
) ([]keyValueGenerator, bool, bool) {
|
||||||
isDynamic := false
|
isDynamic := false
|
||||||
|
keysAreStatic := true
|
||||||
generators := make([]keyValueGenerator, len(items))
|
generators := make([]keyValueGenerator, len(items))
|
||||||
|
|
||||||
for generatorIndex, item := range items {
|
for generatorIndex, item := range items {
|
||||||
@@ -372,6 +423,7 @@ func buildKeyValueGenerators[T keyValueItem](
|
|||||||
keyFunc, keyIsDynamic := createTemplateFunc(keyValue.Key, lazyRoot)
|
keyFunc, keyIsDynamic := createTemplateFunc(keyValue.Key, lazyRoot)
|
||||||
if keyIsDynamic {
|
if keyIsDynamic {
|
||||||
isDynamic = true
|
isDynamic = true
|
||||||
|
keysAreStatic = false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate value functions
|
// Generate value functions
|
||||||
@@ -394,7 +446,7 @@ func buildKeyValueGenerators[T keyValueItem](
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return generators, isDynamic
|
return generators, isDynamic, keysAreStatic
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildStringSliceGenerator(
|
func buildStringSliceGenerator(
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package sarin
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"math/big"
|
"math/big"
|
||||||
"os"
|
"os"
|
||||||
"slices"
|
"slices"
|
||||||
@@ -10,8 +9,8 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/charmbracelet/lipgloss"
|
"charm.land/lipgloss/v2"
|
||||||
"github.com/charmbracelet/lipgloss/table"
|
"charm.land/lipgloss/v2/table"
|
||||||
"go.yaml.in/yaml/v4"
|
"go.yaml.in/yaml/v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -159,7 +158,7 @@ func (data *SarinResponseData) PrintTable() {
|
|||||||
return cellStyle
|
return cellStyle
|
||||||
})
|
})
|
||||||
|
|
||||||
fmt.Println(tbl)
|
lipgloss.Println(tbl)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (data *SarinResponseData) PrintJSON() {
|
func (data *SarinResponseData) PrintJSON() {
|
||||||
|
|||||||
@@ -51,6 +51,18 @@ func SplitLogLevels(levels string) []string {
|
|||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsInteractiveTerminal reports whether fd is a terminal that can actually be
|
||||||
|
// drawn on. A pty reports as a terminal even while its size is still zero, and
|
||||||
|
// Bubble Tea paints into a width x height cell buffer, so a zero dimension
|
||||||
|
// renders nothing at all.
|
||||||
|
func IsInteractiveTerminal(fd uintptr) bool {
|
||||||
|
if !term.IsTerminal(fd) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
width, height, err := term.GetSize(fd)
|
||||||
|
return err == nil && width > 0 && height > 0
|
||||||
|
}
|
||||||
|
|
||||||
// respLogger logs a single completed response.
|
// respLogger logs a single completed response.
|
||||||
type respLogger func(duration time.Duration, resp *fasthttp.Response)
|
type respLogger func(duration time.Duration, resp *fasthttp.Response)
|
||||||
|
|
||||||
@@ -302,7 +314,7 @@ func (s sarin) Start(ctx context.Context, stopCtrl *StopController) {
|
|||||||
totalRequests = *s.totalRequests
|
totalRequests = *s.totalRequests
|
||||||
}
|
}
|
||||||
|
|
||||||
onTerminal := term.IsTerminal(os.Stdout.Fd())
|
onTerminal := IsInteractiveTerminal(os.Stdout.Fd())
|
||||||
// The progress bar needs an interactive terminal to render.
|
// The progress bar needs an interactive terminal to render.
|
||||||
showProgressBar := s.showProgress && onTerminal
|
showProgressBar := s.showProgress && onTerminal
|
||||||
// The bubbletea TUI hosts the bar and/or the live log box, so it runs whenever
|
// The bubbletea TUI hosts the bar and/or the live log box, so it runs whenever
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
tea "github.com/charmbracelet/bubbletea"
|
tea "charm.land/bubbletea/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
const forceExitCode = 130
|
const forceExitCode = 130
|
||||||
|
|||||||
+53
-19
@@ -207,18 +207,20 @@ func NewDefaultTemplateFuncMap(randSource rand.Source, fileCache *FileCache) tem
|
|||||||
|
|
||||||
// Fakeit / Person
|
// Fakeit / Person
|
||||||
// "fakeit_Person": fakeit.Person() *PersonInfo,
|
// "fakeit_Person": fakeit.Person() *PersonInfo,
|
||||||
"fakeit_Name": fakeit.Name,
|
"fakeit_Name": fakeit.Name,
|
||||||
"fakeit_NamePrefix": fakeit.NamePrefix,
|
"fakeit_NamePrefix": fakeit.NamePrefix,
|
||||||
"fakeit_NameSuffix": fakeit.NameSuffix,
|
"fakeit_NameSuffix": fakeit.NameSuffix,
|
||||||
"fakeit_FirstName": fakeit.FirstName,
|
"fakeit_FirstName": fakeit.FirstName,
|
||||||
"fakeit_MiddleName": fakeit.MiddleName,
|
"fakeit_MiddleName": fakeit.MiddleName,
|
||||||
"fakeit_LastName": fakeit.LastName,
|
"fakeit_LastName": fakeit.LastName,
|
||||||
"fakeit_Gender": fakeit.Gender,
|
"fakeit_Gender": fakeit.Gender,
|
||||||
"fakeit_Age": fakeit.Age,
|
"fakeit_Age": fakeit.Age,
|
||||||
"fakeit_Ethnicity": fakeit.Ethnicity,
|
"fakeit_Ethnicity": fakeit.Ethnicity,
|
||||||
"fakeit_SSN": fakeit.SSN,
|
"fakeit_SSN": fakeit.SSN,
|
||||||
"fakeit_EIN": fakeit.EIN,
|
"fakeit_EIN": fakeit.EIN,
|
||||||
"fakeit_Hobby": fakeit.Hobby,
|
"fakeit_Hobby": fakeit.Hobby,
|
||||||
|
"fakeit_SocialMedia": fakeit.SocialMedia,
|
||||||
|
"fakeit_Bio": fakeit.Bio,
|
||||||
// "fakeit_Contact": fakeit.Contact() *ContactInfo,
|
// "fakeit_Contact": fakeit.Contact() *ContactInfo,
|
||||||
"fakeit_Email": fakeit.Email,
|
"fakeit_Email": fakeit.Email,
|
||||||
"fakeit_Phone": fakeit.Phone,
|
"fakeit_Phone": fakeit.Phone,
|
||||||
@@ -232,6 +234,9 @@ func NewDefaultTemplateFuncMap(randSource rand.Source, fileCache *FileCache) tem
|
|||||||
// "fakeit_Generate": fakeit.Generate(value string) string,
|
// "fakeit_Generate": fakeit.Generate(value string) string,
|
||||||
"fakeit_Regex": fakeit.Regex,
|
"fakeit_Regex": fakeit.Regex,
|
||||||
|
|
||||||
|
// Fakeit / Database
|
||||||
|
// "fakeit_SQL": fakeit.SQL(so *SQLOptions) (string, error),
|
||||||
|
|
||||||
// Fakeit / Auth
|
// Fakeit / Auth
|
||||||
"fakeit_Username": fakeit.Username,
|
"fakeit_Username": fakeit.Username,
|
||||||
"fakeit_Password": fakeit.Password,
|
"fakeit_Password": fakeit.Password,
|
||||||
@@ -269,6 +274,15 @@ func NewDefaultTemplateFuncMap(randSource rand.Source, fileCache *FileCache) tem
|
|||||||
return value
|
return value
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Fakeit / Airline
|
||||||
|
"fakeit_AirlineAircraftType": fakeit.AirlineAircraftType,
|
||||||
|
"fakeit_AirlineAirplane": fakeit.AirlineAirplane,
|
||||||
|
"fakeit_AirlineAirport": fakeit.AirlineAirport,
|
||||||
|
"fakeit_AirlineAirportIATA": fakeit.AirlineAirportIATA,
|
||||||
|
"fakeit_AirlineFlightNumber": fakeit.AirlineFlightNumber,
|
||||||
|
"fakeit_AirlineRecordLocator": fakeit.AirlineRecordLocator,
|
||||||
|
"fakeit_AirlineSeat": fakeit.AirlineSeat,
|
||||||
|
|
||||||
// Fakeit / Game
|
// Fakeit / Game
|
||||||
"fakeit_Gamertag": fakeit.Gamertag,
|
"fakeit_Gamertag": fakeit.Gamertag,
|
||||||
// "fakeit_Dice": fakeit.Dice(numDice uint, sides []uint) []uint,
|
// "fakeit_Dice": fakeit.Dice(numDice uint, sides []uint) []uint,
|
||||||
@@ -302,12 +316,16 @@ func NewDefaultTemplateFuncMap(randSource rand.Source, fileCache *FileCache) tem
|
|||||||
"fakeit_NounCollectiveThing": fakeit.NounCollectiveThing,
|
"fakeit_NounCollectiveThing": fakeit.NounCollectiveThing,
|
||||||
"fakeit_NounCountable": fakeit.NounCountable,
|
"fakeit_NounCountable": fakeit.NounCountable,
|
||||||
"fakeit_NounUncountable": fakeit.NounUncountable,
|
"fakeit_NounUncountable": fakeit.NounUncountable,
|
||||||
|
"fakeit_NounProper": fakeit.NounProper,
|
||||||
|
"fakeit_NounDeterminer": fakeit.NounDeterminer,
|
||||||
|
|
||||||
// Verbs
|
// Verbs
|
||||||
"fakeit_Verb": fakeit.Verb,
|
"fakeit_Verb": fakeit.Verb,
|
||||||
"fakeit_VerbAction": fakeit.VerbAction,
|
"fakeit_VerbAction": fakeit.VerbAction,
|
||||||
"fakeit_VerbLinking": fakeit.VerbLinking,
|
"fakeit_VerbLinking": fakeit.VerbLinking,
|
||||||
"fakeit_VerbHelping": fakeit.VerbHelping,
|
"fakeit_VerbHelping": fakeit.VerbHelping,
|
||||||
|
"fakeit_VerbTransitive": fakeit.VerbTransitive,
|
||||||
|
"fakeit_VerbIntransitive": fakeit.VerbIntransitive,
|
||||||
|
|
||||||
// Adverbs
|
// Adverbs
|
||||||
"fakeit_Adverb": fakeit.Adverb,
|
"fakeit_Adverb": fakeit.Adverb,
|
||||||
@@ -344,6 +362,7 @@ func NewDefaultTemplateFuncMap(randSource rand.Source, fileCache *FileCache) tem
|
|||||||
"fakeit_PronounDemonstrative": fakeit.PronounDemonstrative,
|
"fakeit_PronounDemonstrative": fakeit.PronounDemonstrative,
|
||||||
"fakeit_PronounInterrogative": fakeit.PronounInterrogative,
|
"fakeit_PronounInterrogative": fakeit.PronounInterrogative,
|
||||||
"fakeit_PronounRelative": fakeit.PronounRelative,
|
"fakeit_PronounRelative": fakeit.PronounRelative,
|
||||||
|
"fakeit_PronounIndefinite": fakeit.PronounIndefinite,
|
||||||
|
|
||||||
// Connectives
|
// Connectives
|
||||||
"fakeit_Connective": fakeit.Connective,
|
"fakeit_Connective": fakeit.Connective,
|
||||||
@@ -355,7 +374,8 @@ func NewDefaultTemplateFuncMap(randSource rand.Source, fileCache *FileCache) tem
|
|||||||
"fakeit_ConnectiveExamplify": fakeit.ConnectiveExamplify,
|
"fakeit_ConnectiveExamplify": fakeit.ConnectiveExamplify,
|
||||||
|
|
||||||
// Words
|
// Words
|
||||||
"fakeit_Word": fakeit.Word,
|
"fakeit_Word": fakeit.Word,
|
||||||
|
"fakeit_Interjection": fakeit.Interjection,
|
||||||
|
|
||||||
// Text
|
// Text
|
||||||
"fakeit_Sentence": fakeit.Sentence,
|
"fakeit_Sentence": fakeit.Sentence,
|
||||||
@@ -366,6 +386,11 @@ func NewDefaultTemplateFuncMap(randSource rand.Source, fileCache *FileCache) tem
|
|||||||
"fakeit_Question": fakeit.Question,
|
"fakeit_Question": fakeit.Question,
|
||||||
"fakeit_Quote": fakeit.Quote,
|
"fakeit_Quote": fakeit.Quote,
|
||||||
"fakeit_Phrase": fakeit.Phrase,
|
"fakeit_Phrase": fakeit.Phrase,
|
||||||
|
"fakeit_PhraseNoun": fakeit.PhraseNoun,
|
||||||
|
"fakeit_PhraseVerb": fakeit.PhraseVerb,
|
||||||
|
"fakeit_PhraseAdverb": fakeit.PhraseAdverb,
|
||||||
|
"fakeit_PhrasePreposition": fakeit.PhrasePreposition,
|
||||||
|
"fakeit_Comment": fakeit.Comment,
|
||||||
|
|
||||||
// Fakeit / Foods
|
// Fakeit / Foods
|
||||||
"fakeit_Fruit": fakeit.Fruit,
|
"fakeit_Fruit": fakeit.Fruit,
|
||||||
@@ -375,6 +400,7 @@ func NewDefaultTemplateFuncMap(randSource rand.Source, fileCache *FileCache) tem
|
|||||||
"fakeit_Dinner": fakeit.Dinner,
|
"fakeit_Dinner": fakeit.Dinner,
|
||||||
"fakeit_Snack": fakeit.Snack,
|
"fakeit_Snack": fakeit.Snack,
|
||||||
"fakeit_Dessert": fakeit.Dessert,
|
"fakeit_Dessert": fakeit.Dessert,
|
||||||
|
"fakeit_Drink": fakeit.Drink,
|
||||||
|
|
||||||
// Fakeit / Misc
|
// Fakeit / Misc
|
||||||
"fakeit_Bool": fakeit.Bool,
|
"fakeit_Bool": fakeit.Bool,
|
||||||
@@ -387,6 +413,7 @@ func NewDefaultTemplateFuncMap(randSource rand.Source, fileCache *FileCache) tem
|
|||||||
"fakeit_Color": fakeit.Color,
|
"fakeit_Color": fakeit.Color,
|
||||||
"fakeit_HexColor": fakeit.HexColor,
|
"fakeit_HexColor": fakeit.HexColor,
|
||||||
"fakeit_RGBColor": fakeit.RGBColor,
|
"fakeit_RGBColor": fakeit.RGBColor,
|
||||||
|
"fakeit_HSLColor": fakeit.HSLColor,
|
||||||
"fakeit_SafeColor": fakeit.SafeColor,
|
"fakeit_SafeColor": fakeit.SafeColor,
|
||||||
"fakeit_NiceColors": fakeit.NiceColors,
|
"fakeit_NiceColors": fakeit.NiceColors,
|
||||||
|
|
||||||
@@ -530,6 +557,7 @@ func NewDefaultTemplateFuncMap(randSource rand.Source, fileCache *FileCache) tem
|
|||||||
// Fakeit / Language
|
// Fakeit / Language
|
||||||
"fakeit_Language": fakeit.Language,
|
"fakeit_Language": fakeit.Language,
|
||||||
"fakeit_LanguageAbbreviation": fakeit.LanguageAbbreviation,
|
"fakeit_LanguageAbbreviation": fakeit.LanguageAbbreviation,
|
||||||
|
"fakeit_LanguageBCP": fakeit.LanguageBCP,
|
||||||
"fakeit_ProgrammingLanguage": fakeit.ProgrammingLanguage,
|
"fakeit_ProgrammingLanguage": fakeit.ProgrammingLanguage,
|
||||||
|
|
||||||
// Fakeit / Number
|
// Fakeit / Number
|
||||||
@@ -540,25 +568,29 @@ func NewDefaultTemplateFuncMap(randSource rand.Source, fileCache *FileCache) tem
|
|||||||
"fakeit_Int16": fakeit.Int16,
|
"fakeit_Int16": fakeit.Int16,
|
||||||
"fakeit_Int32": fakeit.Int32,
|
"fakeit_Int32": fakeit.Int32,
|
||||||
"fakeit_Int64": fakeit.Int64,
|
"fakeit_Int64": fakeit.Int64,
|
||||||
|
"fakeit_IntRange": fakeit.IntRange,
|
||||||
"fakeit_Uint": fakeit.Uint,
|
"fakeit_Uint": fakeit.Uint,
|
||||||
"fakeit_UintN": fakeit.UintN,
|
"fakeit_UintN": fakeit.UintN,
|
||||||
"fakeit_Uint8": fakeit.Uint8,
|
"fakeit_Uint8": fakeit.Uint8,
|
||||||
"fakeit_Uint16": fakeit.Uint16,
|
"fakeit_Uint16": fakeit.Uint16,
|
||||||
"fakeit_Uint32": fakeit.Uint32,
|
"fakeit_Uint32": fakeit.Uint32,
|
||||||
"fakeit_Uint64": fakeit.Uint64,
|
"fakeit_Uint64": fakeit.Uint64,
|
||||||
|
"fakeit_UintRange": fakeit.UintRange,
|
||||||
"fakeit_Float32": fakeit.Float32,
|
"fakeit_Float32": fakeit.Float32,
|
||||||
"fakeit_Float32Range": fakeit.Float32Range,
|
"fakeit_Float32Range": fakeit.Float32Range,
|
||||||
"fakeit_Float64": fakeit.Float64,
|
"fakeit_Float64": fakeit.Float64,
|
||||||
"fakeit_Float64Range": fakeit.Float64Range,
|
"fakeit_Float64Range": fakeit.Float64Range,
|
||||||
// "fakeit_ShuffleInts": fakeit.ShuffleInts,
|
// "fakeit_ShuffleInts": fakeit.ShuffleInts,
|
||||||
"fakeit_RandomInt": fakeit.RandomInt,
|
"fakeit_RandomInt": fakeit.RandomInt,
|
||||||
"fakeit_HexUint": fakeit.HexUint,
|
"fakeit_RandomUint": fakeit.RandomUint,
|
||||||
|
"fakeit_HexUint": fakeit.HexUint,
|
||||||
|
|
||||||
// Fakeit / String
|
// Fakeit / String
|
||||||
"fakeit_Digit": fakeit.Digit,
|
"fakeit_Digit": fakeit.Digit,
|
||||||
"fakeit_DigitN": fakeit.DigitN,
|
"fakeit_DigitN": fakeit.DigitN,
|
||||||
"fakeit_Letter": fakeit.Letter,
|
"fakeit_Letter": fakeit.Letter,
|
||||||
"fakeit_LetterN": fakeit.LetterN,
|
"fakeit_LetterN": fakeit.LetterN,
|
||||||
|
"fakeit_Vowel": fakeit.Vowel,
|
||||||
"fakeit_Lexify": fakeit.Lexify,
|
"fakeit_Lexify": fakeit.Lexify,
|
||||||
"fakeit_Numerify": fakeit.Numerify,
|
"fakeit_Numerify": fakeit.Numerify,
|
||||||
// "fakeit_ShuffleStrings": fakeit.ShuffleStrings,
|
// "fakeit_ShuffleStrings": fakeit.ShuffleStrings,
|
||||||
@@ -602,12 +634,14 @@ func NewDefaultTemplateFuncMap(randSource rand.Source, fileCache *FileCache) tem
|
|||||||
|
|
||||||
// Fakeit / Error
|
// Fakeit / Error
|
||||||
"fakeit_Error": func() string { return fakeit.Error().Error() },
|
"fakeit_Error": func() string { return fakeit.Error().Error() },
|
||||||
|
"fakeit_ErrorObject": func() string { return fakeit.ErrorObject().Error() },
|
||||||
"fakeit_ErrorDatabase": func() string { return fakeit.ErrorDatabase().Error() },
|
"fakeit_ErrorDatabase": func() string { return fakeit.ErrorDatabase().Error() },
|
||||||
"fakeit_ErrorGRPC": func() string { return fakeit.ErrorGRPC().Error() },
|
"fakeit_ErrorGRPC": func() string { return fakeit.ErrorGRPC().Error() },
|
||||||
"fakeit_ErrorHTTP": func() string { return fakeit.ErrorHTTP().Error() },
|
"fakeit_ErrorHTTP": func() string { return fakeit.ErrorHTTP().Error() },
|
||||||
"fakeit_ErrorHTTPClient": func() string { return fakeit.ErrorHTTPClient().Error() },
|
"fakeit_ErrorHTTPClient": func() string { return fakeit.ErrorHTTPClient().Error() },
|
||||||
"fakeit_ErrorHTTPServer": func() string { return fakeit.ErrorHTTPServer().Error() },
|
"fakeit_ErrorHTTPServer": func() string { return fakeit.ErrorHTTPServer().Error() },
|
||||||
"fakeit_ErrorRuntime": func() string { return fakeit.ErrorRuntime().Error() },
|
"fakeit_ErrorRuntime": func() string { return fakeit.ErrorRuntime().Error() },
|
||||||
|
"fakeit_ErrorValidation": func() string { return fakeit.ErrorValidation().Error() },
|
||||||
|
|
||||||
// Fakeit / School
|
// Fakeit / School
|
||||||
"fakeit_School": fakeit.School,
|
"fakeit_School": fakeit.School,
|
||||||
|
|||||||
+67
-23
@@ -2,19 +2,30 @@ package sarin
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/charmbracelet/bubbles/progress"
|
"charm.land/bubbles/v2/progress"
|
||||||
"github.com/charmbracelet/bubbles/spinner"
|
"charm.land/bubbles/v2/spinner"
|
||||||
tea "github.com/charmbracelet/bubbletea"
|
tea "charm.land/bubbletea/v2"
|
||||||
"github.com/charmbracelet/lipgloss"
|
"charm.land/lipgloss/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type tickMsg time.Time
|
type tickMsg time.Time
|
||||||
|
|
||||||
|
// logBatch carries the log lines accumulated since the last repaint.
|
||||||
|
type logBatch []runtimeLog
|
||||||
|
|
||||||
|
const (
|
||||||
|
// logBoxLines is how many lines the log box shows at once.
|
||||||
|
logBoxLines = 8
|
||||||
|
// logBatchInterval is how often accumulated logs are handed to the program.
|
||||||
|
logBatchInterval = 250 * time.Millisecond
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
helpStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#d1d1d1"))
|
helpStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#d1d1d1"))
|
||||||
errorStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#FC5B5B")).Bold(true)
|
errorStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#FC5B5B")).Bold(true)
|
||||||
@@ -82,22 +93,24 @@ func (m progressModel) Init() tea.Cmd {
|
|||||||
|
|
||||||
func (m progressModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
func (m progressModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||||
switch msg := msg.(type) {
|
switch msg := msg.(type) {
|
||||||
case tea.KeyMsg:
|
case tea.KeyPressMsg:
|
||||||
if msg.Type == tea.KeyCtrlC {
|
if msg.String() == "ctrl+c" {
|
||||||
m.cancelling = true
|
m.cancelling = true
|
||||||
m.stop()
|
m.stop()
|
||||||
}
|
}
|
||||||
return m, nil
|
return m, nil
|
||||||
|
|
||||||
case tea.WindowSizeMsg:
|
case tea.WindowSizeMsg:
|
||||||
m.progress.Width = max(10, msg.Width-1)
|
m.progress.SetWidth(max(10, msg.Width-1))
|
||||||
if m.ctx.Err() != nil {
|
if m.ctx.Err() != nil {
|
||||||
return m, tea.Quit
|
return m, tea.Quit
|
||||||
}
|
}
|
||||||
return m, nil
|
return m, nil
|
||||||
|
|
||||||
case runtimeLog:
|
case logBatch:
|
||||||
m.logs = append(m.logs[1:], renderRuntimeLog(msg))
|
for _, entry := range msg {
|
||||||
|
m.logs = append(m.logs[1:], renderRuntimeLog(entry))
|
||||||
|
}
|
||||||
if m.ctx.Err() != nil {
|
if m.ctx.Err() != nil {
|
||||||
return m, tea.Quit
|
return m, tea.Quit
|
||||||
}
|
}
|
||||||
@@ -117,7 +130,7 @@ func (m progressModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m progressModel) View() string {
|
func (m progressModel) View() tea.View {
|
||||||
var b strings.Builder
|
var b strings.Builder
|
||||||
if box := renderLogBox(m.logs); box != "" {
|
if box := renderLogBox(m.logs); box != "" {
|
||||||
b.WriteString(box)
|
b.WriteString(box)
|
||||||
@@ -138,7 +151,7 @@ func (m progressModel) View() string {
|
|||||||
|
|
||||||
b.WriteString("\n\n ")
|
b.WriteString("\n\n ")
|
||||||
b.WriteString(helpLine(m.cancelling))
|
b.WriteString(helpLine(m.cancelling))
|
||||||
return b.String()
|
return tea.NewView(b.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
func progressTickCmd() tea.Cmd {
|
func progressTickCmd() tea.Cmd {
|
||||||
@@ -167,15 +180,17 @@ func (m infiniteProgressModel) Init() tea.Cmd {
|
|||||||
|
|
||||||
func (m infiniteProgressModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
func (m infiniteProgressModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||||
switch msg := msg.(type) {
|
switch msg := msg.(type) {
|
||||||
case tea.KeyMsg:
|
case tea.KeyPressMsg:
|
||||||
if msg.Type == tea.KeyCtrlC {
|
if msg.String() == "ctrl+c" {
|
||||||
m.cancelling = true
|
m.cancelling = true
|
||||||
m.stop()
|
m.stop()
|
||||||
}
|
}
|
||||||
return m, nil
|
return m, nil
|
||||||
|
|
||||||
case runtimeLog:
|
case logBatch:
|
||||||
m.logs = append(m.logs[1:], renderRuntimeLog(msg))
|
for _, entry := range msg {
|
||||||
|
m.logs = append(m.logs[1:], renderRuntimeLog(entry))
|
||||||
|
}
|
||||||
if m.ctx.Err() != nil {
|
if m.ctx.Err() != nil {
|
||||||
m.quit = true
|
m.quit = true
|
||||||
return m, tea.Quit
|
return m, tea.Quit
|
||||||
@@ -193,7 +208,7 @@ func (m infiniteProgressModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m infiniteProgressModel) View() string {
|
func (m infiniteProgressModel) View() tea.View {
|
||||||
var b strings.Builder
|
var b strings.Builder
|
||||||
if box := renderLogBox(m.logs); box != "" {
|
if box := renderLogBox(m.logs); box != "" {
|
||||||
b.WriteString(box)
|
b.WriteString(box)
|
||||||
@@ -206,7 +221,7 @@ func (m infiniteProgressModel) View() string {
|
|||||||
b.WriteString("\n\n ")
|
b.WriteString("\n\n ")
|
||||||
b.WriteString(helpLine(m.cancelling))
|
b.WriteString(helpLine(m.cancelling))
|
||||||
}
|
}
|
||||||
return b.String()
|
return tea.NewView(b.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.quit {
|
if m.quit {
|
||||||
@@ -227,7 +242,7 @@ func (m infiniteProgressModel) View() string {
|
|||||||
b.WriteString("\n\n ")
|
b.WriteString("\n\n ")
|
||||||
b.WriteString(helpLine(m.cancelling))
|
b.WriteString(helpLine(m.cancelling))
|
||||||
}
|
}
|
||||||
return b.String()
|
return tea.NewView(b.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s sarin) streamProgress(
|
func (s sarin) streamProgress(
|
||||||
@@ -242,9 +257,12 @@ func (s sarin) streamProgress(
|
|||||||
var program *tea.Program
|
var program *tea.Program
|
||||||
if total > 0 {
|
if total > 0 {
|
||||||
model := progressModel{
|
model := progressModel{
|
||||||
progress: progress.New(progress.WithGradient("#151594", "#00D4FF")),
|
progress: progress.New(
|
||||||
|
progress.WithColors(lipgloss.Color("#151594"), lipgloss.Color("#00D4FF")),
|
||||||
|
progress.WithFillCharacters(progress.DefaultFullCharFullBlock, progress.DefaultEmptyCharBlock),
|
||||||
|
),
|
||||||
startTime: time.Now(),
|
startTime: time.Now(),
|
||||||
logs: make([]string, 8),
|
logs: make([]string, logBoxLines),
|
||||||
counter: counter,
|
counter: counter,
|
||||||
maxValue: total,
|
maxValue: total,
|
||||||
showBar: showBar,
|
showBar: showBar,
|
||||||
@@ -275,7 +293,7 @@ func (s sarin) streamProgress(
|
|||||||
),
|
),
|
||||||
startTime: time.Now(),
|
startTime: time.Now(),
|
||||||
counter: counter,
|
counter: counter,
|
||||||
logs: make([]string, 8),
|
logs: make([]string, logBoxLines),
|
||||||
showBar: showBar,
|
showBar: showBar,
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
stop: stopCtrl.Stop,
|
stop: stopCtrl.Stop,
|
||||||
@@ -288,9 +306,35 @@ func (s sarin) streamProgress(
|
|||||||
stopCtrl.AttachProgram(program)
|
stopCtrl.AttachProgram(program)
|
||||||
defer stopCtrl.AttachProgram(nil)
|
defer stopCtrl.AttachProgram(nil)
|
||||||
|
|
||||||
|
// Bubble Tea repaints once per message, so forwarding every log made the run
|
||||||
|
// wait on the terminal. Send only what the box shows, on a fixed cadence.
|
||||||
go func() {
|
go func() {
|
||||||
for msg := range logChannel {
|
ticker := time.NewTicker(logBatchInterval)
|
||||||
program.Send(msg)
|
defer ticker.Stop()
|
||||||
|
|
||||||
|
pending := make(logBatch, 0, logBoxLines)
|
||||||
|
flush := func() {
|
||||||
|
if len(pending) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
program.Send(slices.Clone(pending))
|
||||||
|
pending = pending[:0]
|
||||||
|
}
|
||||||
|
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case entry, ok := <-logChannel:
|
||||||
|
if !ok {
|
||||||
|
flush()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if len(pending) == logBoxLines {
|
||||||
|
pending = append(pending[:0], pending[1:]...)
|
||||||
|
}
|
||||||
|
pending = append(pending, entry)
|
||||||
|
case <-ticker.C:
|
||||||
|
flush()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|||||||
@@ -12,19 +12,19 @@ import (
|
|||||||
const dryRunResponseKey = "dry-run"
|
const dryRunResponseKey = "dry-run"
|
||||||
|
|
||||||
// statusCodeStrings contains pre-computed string representations for HTTP status codes 100-599.
|
// statusCodeStrings contains pre-computed string representations for HTTP status codes 100-599.
|
||||||
var statusCodeStrings = func() map[int]string {
|
var statusCodeStrings = func() [500]string {
|
||||||
m := make(map[int]string, 500)
|
var codes [500]string
|
||||||
for i := 100; i < 600; i++ {
|
for i := range codes {
|
||||||
m[i] = strconv.Itoa(i)
|
codes[i] = strconv.Itoa(i + 100)
|
||||||
}
|
}
|
||||||
return m
|
return codes
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// statusCodeToString returns a string representation of the HTTP status code.
|
// statusCodeToString returns a string representation of the HTTP status code.
|
||||||
// Uses a pre-computed map for codes 100-599, falls back to strconv.Itoa for others.
|
// Uses a pre-computed table for codes 100-599, falls back to strconv.Itoa for others.
|
||||||
func statusCodeToString(code int) string {
|
func statusCodeToString(code int) string {
|
||||||
if s, ok := statusCodeStrings[code]; ok {
|
if i := code - 100; i >= 0 && i < len(statusCodeStrings) {
|
||||||
return s
|
return statusCodeStrings[i]
|
||||||
}
|
}
|
||||||
return strconv.Itoa(code)
|
return strconv.Itoa(code)
|
||||||
}
|
}
|
||||||
@@ -94,7 +94,6 @@ func (s sarin) workerStatsWithDynamic(
|
|||||||
) {
|
) {
|
||||||
for range jobs {
|
for range jobs {
|
||||||
req.Reset()
|
req.Reset()
|
||||||
resp.Reset()
|
|
||||||
|
|
||||||
if err := requestGenerator(req); err != nil {
|
if err := requestGenerator(req); err != nil {
|
||||||
s.responses.Add(err.Error(), 0)
|
s.responses.Add(err.Error(), 0)
|
||||||
@@ -138,8 +137,6 @@ func (s sarin) workerStatsWithStatic(
|
|||||||
}
|
}
|
||||||
|
|
||||||
for range jobs {
|
for range jobs {
|
||||||
resp.Reset()
|
|
||||||
|
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
err := hostClientGenerator().DoTimeout(req, resp, s.timeout)
|
err := hostClientGenerator().DoTimeout(req, resp, s.timeout)
|
||||||
respDuration := time.Since(startTime)
|
respDuration := time.Since(startTime)
|
||||||
@@ -165,7 +162,6 @@ func (s sarin) workerNoStatsWithDynamic(
|
|||||||
) {
|
) {
|
||||||
for range jobs {
|
for range jobs {
|
||||||
req.Reset()
|
req.Reset()
|
||||||
resp.Reset()
|
|
||||||
if err := requestGenerator(req); err != nil {
|
if err := requestGenerator(req); err != nil {
|
||||||
sendLog(runtimeLogLevelError, err.Error())
|
sendLog(runtimeLogLevelError, err.Error())
|
||||||
counter.Add(1)
|
counter.Add(1)
|
||||||
@@ -201,7 +197,6 @@ func (s sarin) workerNoStatsWithStatic(
|
|||||||
}
|
}
|
||||||
|
|
||||||
for range jobs {
|
for range jobs {
|
||||||
resp.Reset()
|
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
err := hostClientGenerator().DoTimeout(req, resp, s.timeout)
|
err := hostClientGenerator().DoTimeout(req, resp, s.timeout)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|||||||
+9
-9
@@ -1,17 +1,18 @@
|
|||||||
{ lib
|
{
|
||||||
, buildGoModule
|
lib,
|
||||||
, go_1_26
|
buildGoModule,
|
||||||
, rev ? "unknown"
|
go_1_27,
|
||||||
, buildDate ? "unknown"
|
rev ? "unknown",
|
||||||
|
buildDate ? "unknown",
|
||||||
}:
|
}:
|
||||||
|
|
||||||
(buildGoModule.override { go = go_1_26; }) (finalAttrs: {
|
(buildGoModule.override { go = go_1_27; }) (finalAttrs: {
|
||||||
pname = "sarin";
|
pname = "sarin";
|
||||||
version = "1.4.0"; # bump per release
|
version = "1.4.4"; # bump per release
|
||||||
|
|
||||||
src = lib.cleanSource ../.;
|
src = lib.cleanSource ../.;
|
||||||
|
|
||||||
vendorHash = "sha256-/r2mioVoMbrboumF0sjHhharkGImQAShmiOQtdS5DaE=";
|
vendorHash = "sha256-77wMBIhsXUwZ97iAaJivB7qOuQhBZ1LJphnRWfUTjJo=";
|
||||||
|
|
||||||
subPackages = [ "cmd/cli" ];
|
subPackages = [ "cmd/cli" ];
|
||||||
|
|
||||||
@@ -29,7 +30,6 @@
|
|||||||
ldflags+=("-X 'go.aykhans.me/sarin/internal/version.GoVersion=$(go version)'")
|
ldflags+=("-X 'go.aykhans.me/sarin/internal/version.GoVersion=$(go version)'")
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# cmd/cli produces a binary named "cli"; rename it to "sarin".
|
|
||||||
postInstall = ''
|
postInstall = ''
|
||||||
mv $out/bin/cli $out/bin/sarin
|
mv $out/bin/cli $out/bin/sarin
|
||||||
'';
|
'';
|
||||||
|
|||||||
Reference in new issue
Block a user