Skip to main content

YAML-driven CLI framework — turn any REST API into CLI commands

Project description

cliyard

CLI + YAML + Yard — a framework that generates CLI commands from YAML specs. Define your REST API in a few YAML files, and cliyard produces a fully-structured Click CLI with parameters, types, and auto-generated help. Originally inspired by ketacli's YAML-driven architecture, now generalized for any REST API.

Installation

pip install cliyard

For local development:

pip install -e .

Quick Start

# Explore the example spec
cliyard --spec-dir examples/ketacli-repos/ repos list --help

# Usage: repos list [OPTIONS]
#   --page INTEGER        Page number
#   --search TEXT         Search keyword
#   --help                Show this message and exit.

How It Works

cliyard turns a directory of YAML files into CLI commands. One directory equals one API service. Each YAML file (except _service.yaml) becomes a resource group with subcommands for every defined method.

your-api/                          ┌─────────────────────────────────┐
├── _service.yaml  ── service ──►  │  cliyard Engine                 │
├── repos.yaml     ── resource ──► │                                 │
├── users.yaml     ── resource ──► │  Loader ──► Builder ──► Click   │
└── ...                            │    │            │           │    │
                                   │    │     Auth Chain          │    │
                                   │    ▼            ▼           ▼    │
                                   │  YAML       Commands    CLI run  │
                                   │  parsing    + params              │
                                   └─────────────────────────────────┘

Data flow for a single invocation:

cliyard --spec-dir examples/ketacli-repos/ repos list --page 1

    1. Loader reads _service.yaml + repos.yaml
    2. Auth chain runs (env → login → inject token)
    3. Builder generates Click commands from method specs
    4. Params are typed (int, string, enum, bool) and validated
    5. (Future) HTTP request is assembled and sent
    6. (Future) Response is formatted with Rich tables

Directory Structure

Each service is a directory containing a _service.yaml for service-level config and one YAML file per resource:

ketacli-repos/
├── _service.yaml      # Service config: name, server, auth
└── repos.yaml         # Resource: repos (list, create, get, update, delete)
  • _service.yaml defines the server URL, authentication chain, and global settings.
  • Resource files (repos.yaml, users.yaml, etc.) define the methods, parameters, and output format for each API resource.
  • Files prefixed with _service. (like _service.local.yaml) are reserved for future local overrides and are ignored during loading.

Comparison with ketacli

Feature cliyard ketacli
API scope Any REST API KetaDB only
Config format One directory per API service Single YAML tree per resource
Auth model Chain-based (env, login, inject) Built-in, KetaDB-specific
Auth caching In-memory TTL token cache Session-based
Param types string, int, float, bool, enum Pre-defined per command
Adding resources Add a YAML file to the directory Requires code changes
CLI generation Dynamic from spec at runtime Pre-built Click commands
Purpose General-purpose API-to-CLI framework KetaDB management tool

Creating Your Own Spec

See examples/README.md for a step-by-step guide to creating new API specs.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cliyard-0.3.2.tar.gz (59.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cliyard-0.3.2-py3-none-any.whl (59.4 kB view details)

Uploaded Python 3

File details

Details for the file cliyard-0.3.2.tar.gz.

File metadata

  • Download URL: cliyard-0.3.2.tar.gz
  • Upload date:
  • Size: 59.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for cliyard-0.3.2.tar.gz
Algorithm Hash digest
SHA256 283cb55885e528471a5637cb6045b552cc92bf159ce298c50953cd80036519fe
MD5 e7a70249263974dcbf44b818da6211f2
BLAKE2b-256 b75e5d5e4d51c69f2461ee501468542e96de09adfe2fd3eb742a35d9b566f912

See more details on using hashes here.

Provenance

The following attestation bundles were made for cliyard-0.3.2.tar.gz:

Publisher: publish.yml on guolong123/cliyard

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cliyard-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: cliyard-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 59.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for cliyard-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4322c7816e8ea3fa41757da5162b24d460f87ea5ceb6f275a4311c210757b4fd
MD5 f83886833d2b9cf1440051325da5b7e0
BLAKE2b-256 6e2b3cab9a434991e1b071b82b40e43dbd71c1618f3a1025f514073314faa561

See more details on using hashes here.

Provenance

The following attestation bundles were made for cliyard-0.3.2-py3-none-any.whl:

Publisher: publish.yml on guolong123/cliyard

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page