Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Rempts Examples

This directory contains example Rempts CLI applications demonstrating various features and patterns, organized from simple to complex.

Examples Overview

hello-world

The absolute simplest possible Rempts CLI with a single command. Perfect starting point to understand the basics.

  • Basic command definition
  • Simple flag handling
  • Minimal configuration
  • Type generation for enhanced DX

task-runner

A practical task automation CLI showcasing validation and interactivity patterns.

  • Schema validation with Zod
  • Interactive prompts and confirmations
  • Progress indicators and spinners
  • Build, test, deploy, and setup workflows
  • Conditional flows based on options

git-tool

A Git workflow helper demonstrating command organization and external tool integration.

  • Nested command structure
  • Command aliases
  • Integration with external tools (git)
  • Shell command execution
  • Colored output for status

dev-server

A development server CLI showcasing advanced plugin system and configuration management.

  • Plugin system with lifecycle hooks
  • Type-safe plugin context
  • Configuration management
  • Long-running processes
  • Real-time updates and log following

Getting Started

Each example demonstrates the recommended Rempts development workflow:

# Navigate to an example
cd hello-world

# Install dependencies (includes @reliverse/dler rempts CLI)
bun install

# Generate types (creates .dler/commands.gen.ts)
bun run generate

# Start development with hot reload
bun run dev

# Build for production
bun run build

# Run the built executable
bun run start

# Or run directly (without hot reload)
bun cli.ts

All examples include:

  • dler.config.ts - Configuration with required commands.directory
  • commands/ directory - All command definitions (REQUIRED structure)
  • .dler/commands.gen.ts - Generated TypeScript definitions (auto-created)
  • Development scripts using rempts dev for hot reload
  • Build scripts using rempts build for production
  • Type generation for enhanced developer experience

Progression Path

Follow this learning path to master Rempts:

  1. hello-world (5 min) - Learn the absolute basics
  2. task-runner (15 min) - Validation and interactivity
  3. git-tool (15 min) - Command structure and organization
  4. dev-server (20 min) - Plugins and advanced patterns

Each example builds on the previous concepts and introduces new patterns.

Key Concepts

Schema-Driven Options

Rempts uses Standard Schema for validation, allowing you to use any compatible validation library:

import { defineCommand, option } from '@reliverse/rempts'
import { type } from 'arktype'

export default defineCommand({
  options: {
    port: option(
      type("number", { min: 1000, max: 65535 }),
      { short: 'p', description: 'Port number' }
    )
  }
})

Command Organization

For larger CLIs, organize commands in a clear structure:

// commands/mod.ts
export const commands = [
  buildCommand,
  testCommand,
  deployCommand
]

Interactive Prompts

Create engaging CLI experiences with built-in prompts:

const name = await prompt.text('What is your name?')
const color = await prompt.select('Favorite color?', ['red', 'green', 'blue'])
const confirmed = await prompt.confirm('Continue?')

Plugin System

Extend functionality with type-safe plugins:

import { createPlugin } from '@reliverse/rempts/plugin'

export const myPlugin = createPlugin({
  name: 'my-plugin',
  store: { count: 0 },
  beforeCommand({ store }) {
    store.count++
  }
})

Building for Distribution

All examples use dler.config.ts for build configuration:

// dler.config.ts
import { defineConfig } from '@reliverse/rempts'

export default defineConfig({
  name: 'my-cli',
  version: '1.0.0',
  description: 'My awesome CLI',

  // REQUIRED: commands directory
  commands: {
    directory: './commands'
  },

  // REQUIRED: plugins array (can be empty)
  plugins: [],

  build: {
    entry: './cli.ts',
    outdir: './dist',
    targets: ['native'],  // Default target
    compress: false,      // Default: false
    minify: false,        // Default: false
    sourcemap: true       // Default: true
  },

  dev: {
    watch: true,
    inspect: false
  }
})

Build commands:

# Build for current platform
bun run build

# Build for specific platforms
rempts build --targets darwin-arm64,linux-x64

# Build for all platforms
rempts build --targets all

# Build with custom settings
rempts build --minify --sourcemap

The Rempts CLI handles:

  • Hot reload in development (rempts dev)
  • Standalone executable creation with Bun's --compile flag
  • Multi-platform builds
  • Automatic compression for releases

Learn More

License

MIT