Workspace Tool (wst) - 4-Way CLI Comparison

A simple workspace management CLI tool implemented in 4 different languages to demonstrate CLI best practices across ecosystems.

Overview

wst helps manage workspace directories and their associated environment variables. This project implements the same tool in Python (Typer), TypeScript/Bun, Go (Cobra), and Rust (Clap) to compare approaches, performance, and developer experience.

Features

  • Config Management: Initialize and manage configuration files
  • Workspace Attachment: Link workspace directories to the tool
  • Environment Generation: Output shell-compatible environment variables
  • Cross-Platform: Works on macOS, Linux, and Windows

Quick Start

Commands

# Initialize config
wst config init
 
# Attach current directory as workspace
wst attach
 
# Attach specific directory
wst attach /path/to/workspace
 
# Load environment variables (use with eval)
eval "$(wst env)"
 
# View configuration
wst config show

Configuration

Configuration is stored in ~/.config/wst/config.yaml:

workspace:
  path: /Users/rmac/Workspace/MyProject
  name: MyProject
environment:
  WST_WORKSPACE: "{{workspace.path}}"
  WST_PROJECT: "{{workspace.name}}"
  PATH: "{{workspace.path}}/bin:$PATH"
settings:
  auto_attach: false
  shell: bash

Implementations

Python (Typer)

Framework: Typer with Rich for output File: python/wst.py Distribution: Single-file with inline dependencies (PEP 723)

# Run with UV
uv run python/wst.py --help
 
# Or with shebang
./python/wst.py --help

Pros:

  • Quick development
  • Excellent type hints
  • Beautiful terminal output with Rich
  • Single file deployment

Cons:

  • Requires Python runtime
  • Slower startup time
  • Larger memory footprint

TypeScript/Bun

Framework: Commander.js Files: typescript/src/wst.ts Distribution: Compiled binary or direct execution

# Install dependencies
cd typescript && bun install
 
# Run directly
bun run src/wst.ts --help
 
# Build standalone binary
bun build --compile src/wst.ts --outfile wst
./wst --help

Pros:

  • Fast execution with Bun
  • Type-safe with TypeScript
  • Can compile to single binary
  • Familiar syntax for JS/TS developers

Cons:

  • Bun is relatively new
  • Larger binary size when compiled
  • Node.js ecosystem complexity

Go (Cobra)

Framework: Cobra + Viper Files: go/main.go and go/cmd/ Distribution: Single static binary

# Build
cd go && go build -o wst
 
# Run
./wst --help
 
# Install
go install

Pros:

  • Fast compilation and execution
  • Small static binary
  • Excellent cross-compilation
  • Industry-standard patterns

Cons:

  • More verbose than Python/TypeScript
  • Steeper learning curve
  • Requires understanding of Go modules

Rust (Clap)

Framework: Clap v4 with derive API Files: rust/src/main.rs and rust/src/commands/ Distribution: Single static binary

# Build
cd rust && cargo build --release
 
# Run
./target/release/wst --help
 
# Install
cargo install --path .

Pros:

  • Fastest runtime performance
  • Memory safe by design
  • Excellent error handling
  • Small binary size

Cons:

  • Longest compilation time
  • Steepest learning curve
  • Borrow checker complexity

Comparison

See COMPARISON.md for detailed side-by-side comparison including:

  • Installation & setup complexity
  • Code organization patterns
  • Framework capabilities
  • Performance benchmarks
  • Distribution methods
  • Best practices per language

Performance Summary

ImplementationStartup TimeBinary SizeBuild TimeMemory Usage
Python~150msN/AN/A~30MB
TypeScript/Bun~50ms~50MB~2s~20MB
Go~5ms~8MB~3s~5MB
Rust~3ms~4MB~30s~3MB

Benchmarks run on Apple M1 Pro, macOS Sonoma

Testing

Each implementation passes the same test suite:

# Run tests for all implementations
./test-all.sh
 
# Test specific implementation
./test-python.sh
./test-typescript.sh
./test-go.sh
./test-rust.sh

Why This Comparison?

Unlike the Gmail CLI project, wst focuses on simpler operations:

  • No OAuth or API integration
  • No network calls
  • Focus on file I/O and shell integration
  • Demonstrates config management patterns
  • Shows environment variable generation

This makes it easier to understand the core differences in CLI patterns across languages without the complexity of external API integration.

Project Goals

  1. Educational: Demonstrate CLI best practices in each language
  2. Practical: Create a useful workspace management tool
  3. Comparative: Show trade-offs between implementation approaches
  4. Reference: Provide templates for future CLI projects

License

MIT

Author

justbry (via HAPI)