HN
Today

Show HN: Crust – A CLI framework for TypeScript and Bun

Crust is a new CLI framework built specifically for TypeScript and Bun, aiming to strike a balance between minimal argument parsers and large, dependency-heavy frameworks. It stands out with full type inference, compile-time validation, and a tiny footprint thanks to zero runtime dependencies. The project appeals to developers seeking a modern, lightweight, and type-safe solution for building command-line interfaces in the JavaScript ecosystem, particularly those leveraging Bun.

8
Score
0
Comments
#12
Highest Rank
3h
on Front Page
First Seen
Mar 17, 5:00 PM
Last Seen
Mar 17, 7:00 PM
Rank Over Time
161213

The Lowdown

Crust is an open-source CLI (Command Line Interface) framework designed from the ground up for TypeScript and the Bun runtime. Developed internally for a product, it addresses a common developer pain point: existing JavaScript CLI tools are either overly simplistic or bloated with dependencies and Node.js-era assumptions. Crust positions itself as a streamlined yet powerful alternative.

  • TypeScript-First & Bun-Native: It fully embraces TypeScript for type safety and is optimized for the Bun runtime, consciously avoiding Node.js compatibility layers.
  • Smart Type Inference: The framework automatically infers types for arguments and flags from their definitions, eliminating the need for manual type annotations.
  • Proactive Validation: It incorporates compile-time validation to detect errors like flag alias collisions and variadic argument mistakes before runtime execution.
  • Featherlight Footprint: With zero runtime dependencies, the core package (@crustjs/core) is exceptionally small at ~3.6kB gzipped, significantly lighter than alternatives like yargs (509kB) or oclif (411kB).
  • Modular Design: Crust is built with composable modules, allowing users to install only the necessary packages for core functionality, plugins, prompts, styling, and validation.
  • Extensible Plugin System: It features a middleware-based plugin system with lifecycle hooks (preRun/postRun), offering official plugins for common features like help, version display, and shell autocompletion.

By offering a type-safe, dependency-free, and Bun-optimized experience, Crust aims to provide a more efficient and developer-friendly approach to crafting command-line tools in the modern JavaScript landscape.