mocklet_cli

module
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2026 License: Apache-2.0

README

mocklet-cli

Thin Go CLI wrapper for the Mocklet HTTP API, aligned with cli_arch_draft.md.

Current status:

  • Sprint 1 foundation is complete;
  • Sprint 2 platform baseline is implemented (generated client, cobra shell, config/profile/token/output scaffolding);
  • Sprint 3 auth MVP is implemented (auth login/whoami/logout/token set --stdin, including CLI Google flow);
  • Sprint 4 upload MVP is implemented (mock validate and mock create with file + raw/stdin transport paths);
  • Sprint 5 lifecycle and release hardening is implemented (mock list/get/stats/restart/delete, output stabilization, release smoke checks);
  • command surface v1 is fixed in docs/commands.md;
  • local runtime scope is removed from CLI v1;
  • CI uses GitLab (.gitlab-ci.yml) with baseline quality gates;
  • OpenAPI generation workflow is fixed and documented.

Layout

Key paths:

  • cmd/mocklet: binary entrypoint
  • internal/cli: CLI command routing and UX shell
  • internal/cloud/openapi: reserved package for generated OpenAPI client code
  • internal/cloud: thin wrappers and transport error classification
  • internal/output: exit code mapping and renderer skeleton
  • internal/auth: token store abstraction (flag/env/keyring/file)
  • internal/config: profiles and precedence resolution (flags > env > profile > defaults)
  • docs: architecture and contract notes
  • scripts: local quality and generation helpers
  • Makefile: reproducible local workflow entrypoints
  • .gitlab-ci.yml: GitLab CI checks and tag-based release workflow

Commands

Auth commands are implemented and ready for manual and CI usage:

go run ./cmd/mocklet auth login --email user@example.com --password-stdin
go run ./cmd/mocklet auth login --google
go run ./cmd/mocklet auth whoami
go run ./cmd/mocklet auth token set --stdin
go run ./cmd/mocklet auth logout

Mock upload commands are implemented:

go run ./cmd/mocklet mock validate ./sample.har
cat ./sample.har | go run ./cmd/mocklet mock validate --stdin --output json
go run ./cmd/mocklet mock create ./sample.har --ttl-seconds 86400 --latency-emulation
cat ./sample.har | go run ./cmd/mocklet mock create --stdin --matching-rules-file ./matching_rules.json --output json

Mock lifecycle commands are implemented:

go run ./cmd/mocklet mock list --limit 20 --output table
go run ./cmd/mocklet mock get abc123 --output json
go run ./cmd/mocklet mock stats abc123 --history-limit 20 --output json
go run ./cmd/mocklet mock restart abc123
go run ./cmd/mocklet mock delete abc123 --yes

Command tree and flags are documented in docs/commands.md.

Local workflow

make build
make test
make vet
make lint
make security
make coverage
make race
make openapi-smoke
make release-smoke

CI-equivalent local check:

make ci

OpenAPI generation

Use:

make openapi-smoke
make openapi-generate

Details are documented in docs/openapi-generation.md.

Notes

Directories

Path Synopsis
cmd
mocklet command
internal
auth
Package auth contains authentication flows and token storage adapters.
Package auth contains authentication flows and token storage adapters.
cli
cloud
Package cloud contains API clients for Mocklet cloud services.
Package cloud contains API clients for Mocklet cloud services.
cloud/openapi
Package openapi provides primitives to interact with the openapi HTTP API.
Package openapi provides primitives to interact with the openapi HTTP API.
config
Package config contains profile and configuration loading logic.
Package config contains profile and configuration loading logic.
output
Package output contains output contracts and exit code helpers.
Package output contains output contracts and exit code helpers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL