cliforge

module
v0.0.0-...-0bc6d30 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2025 License: MIT

README

CliForge

Dynamic CLI generation from OpenAPI specifications.

CliForge combines static branded binaries with dynamic spec loading to create professional, self-updating command-line tools from OpenAPI specifications.

Status Coverage CI Go Report Card


What is CliForge?

CliForge generates branded CLI tools that load OpenAPI specifications at runtime. This hybrid approach delivers professional, distributable binaries while maintaining the flexibility of dynamic spec loading.

Key Features:

  • Hybrid architecture - Static branded binary + dynamic spec loading
  • Self-updating - Security patches and config changes delivered seamlessly
  • Zero code generation - No generated files in your repository
  • OpenAPI-driven - Your spec is the single source of truth
  • Configuration DSL - YAML-based configuration for branding and behavior
  • XDG-compliant - Follows standard directory conventions

Architecture

CliForge uses a tri-level separation model:

Binary Level:

  • Embedded configuration and branding
  • Self-update mechanism
  • Runtime engine

API Level:

  • OpenAPI spec loaded at runtime (cached 5min)
  • Paths → Commands
  • Operations → Subcommands
  • Parameters → Flags

Behavioral Level:

  • Authentication strategies
  • Output formatting
  • Rate limiting
  • Workflow orchestration

Update Flow:

  • Binary changes (branding, security) → Self-update
  • API changes (new endpoints) → Spec reload
  • Config changes (auth, rate limits) → Config update

Configuration

Example cli-config.yaml:

metadata:
  name: my-api-cli
  version: 1.0.0
  description: My API Command Line Interface

branding:
  colors:
    primary: "#FF6B35"
  ascii_art: |
    ╔════════════════════════╗
    ║   My Amazing API CLI   ║
    ╚════════════════════════╝

api:
  openapi_url: https://api.example.com/openapi.yaml
  base_url: https://api.example.com

updates:
  enabled: true
  update_url: https://releases.example.com/my-api-cli

behaviors:
  auth:
    type: api_key
    api_key:
      header: X-API-Key
      env_var: MY_API_KEY
  output:
    default_format: json
    pretty_print: true

See Configuration DSL Reference for complete documentation.


Advanced Features

Workflow Orchestration

Define multi-step API workflows with x-cli-workflow:

paths:
  /deploy:
    post:
      operationId: deployApp
      x-cli-workflow:
        steps:
          - id: check-readiness
            request:
              method: GET
              url: "{base_url}/readiness"

          - id: create-deployment
            request:
              method: POST
              url: "{base_url}/deployments"
              body:
                app: "{args.app_id}"
            condition: "check-readiness.body.ready == true"

        output:
          transform: |
            {
              "deployment_id": create-deployment.body.id,
              "status": create-deployment.body.status
            }
Change Detection

Automatically notify users of API changes:

info:
  x-cli-changelog:
    - date: "2025-01-11"
      version: "2.1.0"
      changes:
        - type: added
          severity: safe
          description: "New analytics endpoint"
        - type: deprecated
          severity: dangerous
          description: "GET /v1/users deprecated"
          migration: "Use GET /v2/users instead"
          sunset: "2025-12-31"

Documentation

User Documentation
Design Documentation
  • Architecture - Architecture and design documents
  • ADRs - Architecture Decision Records
  • Research - Technology analysis and comparisons

Technology Stack


Development

# Clone repository
git clone https://github.com/cliforge/cliforge.git
cd cliforge

# Install dependencies
go mod download

# Run tests
go test ./...

# Build
go build ./...

See CONTRIBUTING.md for commit guidelines and development workflow.


Project Status

CliForge v0.9.0 is feature complete with full implementation.

Implemented:

  • Complete OpenAPI 3.x and Swagger 2.0 parser
  • Configuration system with override matrix
  • Plugin architecture for external tool integration
  • Workflow orchestration engine with DAG execution
  • Authentication (API key, Basic, OAuth2 with all flows)
  • State management and context system
  • Output formatting (JSON, YAML, tables)
  • Progress indicators and streaming (SSE, WebSocket)
  • Secrets detection and masking
  • Deprecation warnings with migration assistance
  • Self-update mechanism
  • All built-in commands
  • Generator CLI (cliforge init/build/validate)

Test Coverage:

  • 14/17 packages passing all tests
  • Average coverage: 51.8%
  • High coverage in critical areas (state: 87%, output: 76%, secrets: 75%)

Next:

  • Performance optimization
  • Enhanced integration testing
  • Production deployment examples

Why CliForge?

Existing tools require tradeoffs:

Static Generators (OpenAPI Generator, swagger-codegen):

  • Generate branded binaries
  • Require regeneration for API changes
  • No self-updating capability

Dynamic Loaders (Restish, openapi-cli):

  • Load specs dynamically
  • Cannot be branded or distributed as standalone tools

CliForge provides both:

  • Branded, distributable binaries
  • Dynamic API updates
  • Self-updating for security
  • Change notifications
  • Workflow orchestration

License

MIT License - See LICENSE for details.


Directories

Path Synopsis
cmd
cliforge command
Package main implements the CliForge generator CLI.
Package main implements the CliForge generator CLI.
examples
petstore command
internal
builder
Package builder converts OpenAPI specs to Cobra command trees.
Package builder converts OpenAPI specs to Cobra command trees.
embed
Package embed handles embedding configuration into generated CLI binaries.
Package embed handles embedding configuration into generated CLI binaries.
executor
Package executor provides confirmation prompt functionality for destructive operations.
Package executor provides confirmation prompt functionality for destructive operations.
runtime
Package runtime provides the runtime environment for generated CLIs.
Package runtime provides the runtime environment for generated CLIs.
pkg
auth
Package auth provides authentication mechanisms for CLI applications.
Package auth provides authentication mechanisms for CLI applications.
auth/storage
Package storage provides token storage implementations for authentication.
Package storage provides token storage implementations for authentication.
auth/types
Package types defines common types used across the auth package.
Package types defines common types used across the auth package.
cache
Package cache provides XDG-compliant caching for OpenAPI specifications.
Package cache provides XDG-compliant caching for OpenAPI specifications.
cli
Package cli defines the core types for CliForge CLI generation system.
Package cli defines the core types for CliForge CLI generation system.
cli/interactive
Package interactive provides interactive prompt functionality for CLI operations.
Package interactive provides interactive prompt functionality for CLI operations.
config
Package config handles loading, merging, and validation of CLI configurations.
Package config handles loading, merging, and validation of CLI configurations.
deprecation
Package deprecation provides deprecation detection and management for CliForge.
Package deprecation provides deprecation detection and management for CliForge.
openapi
Package openapi provides OpenAPI 3.x and Swagger 2.0 specification parsing with CLI extensions support.
Package openapi provides OpenAPI 3.x and Swagger 2.0 specification parsing with CLI extensions support.
output
Package output provides output formatting for CLI command responses.
Package output provides output formatting for CLI command responses.
plugin
Package plugin provides a plugin architecture for extending CliForge capabilities.
Package plugin provides a plugin architecture for extending CliForge capabilities.
plugin/builtin
Package builtin provides built-in plugins that ship with CliForge.
Package builtin provides built-in plugins that ship with CliForge.
progress
Package progress provides visual progress indicators for long-running CLI operations.
Package progress provides visual progress indicators for long-running CLI operations.
secrets
Package secrets provides multi-layer secret detection and masking for CliForge.
Package secrets provides multi-layer secret detection and masking for CliForge.
state
Package state manages CLI state, contexts, history, and recent values.
Package state manages CLI state, contexts, history, and recent values.
update
Package update provides self-update capabilities for CliForge-generated CLIs.
Package update provides self-update capabilities for CliForge-generated CLIs.
workflow
Package workflow provides multi-step API workflow orchestration for CliForge.
Package workflow provides multi-step API workflow orchestration for CliForge.
tests
helpers
Package helpers provides test helper functions for integration tests.
Package helpers provides test helper functions for integration tests.

Jump to

Keyboard shortcuts

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