cafef-cli

module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: Apache-2.0

README

cafef

A command line for cafef.

cafef is a single pure-Go binary. It reads public cafef data over plain HTTPS, shapes it into clean records, and prints output that pipes into the rest of your tools. No API key, nothing to run alongside it.

The same package is also a resource-URI driver, so a host program like ant can address cafef as cafef:// URIs.

Install

go install github.com/tamnd/cafef-cli/cmd/cafef@latest

Or grab a prebuilt binary from the releases, or run the container image:

docker run --rm ghcr.io/tamnd/cafef:latest --help

Usage

cafef page <path>                      # fetch one page as a record
cafef page <path> -o json              # as JSON, ready for jq
cafef page <path> --template '{{.Body}}'  # just the readable body text
cafef links <path>                     # the pages it links to, one per line
cafef --help                           # the whole command tree

Every command shares one output contract: -o table|json|jsonl|csv|tsv|url|raw, --fields to pick columns, --template for a custom line, and -n to limit. The default adapts to where output goes (a table on a terminal, JSONL in a pipe), so the same command reads well by hand and parses cleanly downstream.

This is a fresh scaffold. It ships one example resource type, page, wired end to end. Model the real cafef records in cafef/ and declare their operations in cafef/domain.go; each one becomes a command, an HTTP route, and an MCP tool at once.

Serve it

The same operations are available over HTTP and as an MCP tool set for agents, with no extra code:

cafef serve --addr :7777    # GET /v1/page/<path>  returns NDJSON
cafef mcp                   # speak MCP over stdio

Use it as a resource-URI driver

cafef registers a cafef domain the way a program registers a database driver with database/sql. A host enables it with one blank import:

import _ "github.com/tamnd/cafef-cli/cafef"

Then ant (or any program that links the package) dereferences cafef:// URIs without knowing anything about cafef:

ant get cafef://page/<path>   # fetch the record
ant cat cafef://page/<path>   # just the body text
ant ls  cafef://page/<path>   # the pages it links to, each addressable
ant url cafef://page/<path>   # the live https URL

Development

cmd/cafef/   thin main: hands cli.NewApp to kit.Run
cli/                 assembles the kit App from the cafef domain
cafef/                the library: HTTP client, data models, and domain.go (the driver)
docs/                tago documentation site
make build      # ./bin/cafef
make test       # go test ./...
make vet        # go vet ./...

Releasing

Push a version tag and GitHub Actions runs GoReleaser, which builds the archives, Linux packages, the multi-arch GHCR image, checksums, SBOMs, and a cosign signature:

git tag v0.1.0
git push --tags

The Homebrew and Scoop steps self-disable until their tokens exist, so the first release works with no extra secrets.

License

Apache-2.0. See LICENSE.

Directories

Path Synopsis
Package cafef is the library behind the cafef command line: the HTTP client, HTML scraping, and typed data models for CafeF (cafef.vn), Vietnam's leading financial news and stock-market portal.
Package cafef is the library behind the cafef command line: the HTTP client, HTML scraping, and typed data models for CafeF (cafef.vn), Vietnam's leading financial news and stock-market portal.
Package cli assembles the cafef command tree from the cafef domain on top of the any-cli/kit framework.
Package cli assembles the cafef command tree from the cafef domain on top of the any-cli/kit framework.
cmd
cafef command
Command cafef is a single-binary command line for cafef.
Command cafef is a single-binary command line for cafef.

Jump to

Keyboard shortcuts

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