{"by":"jellyotsiro","descendants":38,"id":47408727,"kids":[47416337,47420438,47422358,47416015,47421701,47526337,47417832,47415751,47419691,47416483,47437195,47415769,47417551,47416193,47423389,47434338,47424106,47434240,47423473,47421700],"score":95,"text":"We&#x27;ve been building Crust (<a href=\"https:&#x2F;&#x2F;crustjs.com&#x2F;\" rel=\"nofollow\">https:&#x2F;&#x2F;crustjs.com&#x2F;</a>), a TypeScript-first, Bun-native CLI framework with zero dependencies. It&#x27;s been powering our core product internally for a while, and we&#x27;re now open-sourcing it.<p>The problem we kept running into: existing CLI frameworks in the JS ecosystem are either minimal arg parsers where you wire everything yourself, or heavyweight frameworks with large dependency trees and Node-era assumptions. We wanted something in between.<p>What Crust does differently:<p>- Full type inference from definitions — args and flags are inferred automatically. No manual type annotations, no generics to wrangle. You define a flag as type: &quot;string&quot; and it flows through to your handler.<p>- Compile-time validation — catches flag alias collisions and variadic arg mistakes before your code runs, not at runtime.<p>- Zero runtime dependencies — @crustjs&#x2F;core is ~3.6kB gzipped (21kB install). For comparison: yargs is 509kB, oclif is 411kB.<p>- Composable modules — core, plugins, prompts, styling, validation, and build tooling are all separate packages. Install only what you need.<p>- Plugin system — middleware-based with lifecycle hooks (preRun&#x2F;postRun). Official plugins for help, version, and shell autocompletion.<p>- Built for Bun — no Node compatibility layers, no legacy baggage.<p>Quick example:<p><pre><code>  import { Crust } from &quot;@crustjs&#x2F;core&quot;;\n  import { helpPlugin, versionPlugin } from &quot;@crustjs&#x2F;plugins&quot;;\n\n  const main = new Crust(&quot;greet&quot;)\n    .args([{ name: &quot;name&quot;, type: &quot;string&quot;, default: &quot;world&quot; }])\n    .flags({ shout: { type: &quot;boolean&quot;, short: &quot;s&quot; } })\n    .use(helpPlugin())\n    .use(versionPlugin(&quot;1.0.0&quot;))\n    .run(({ args, flags }) =&gt; {\n      const msg = `Hello, ${args.name}!`;\n      console.log(flags.shout ? msg.toUpperCase() : msg);\n    });\n\n  await main.execute();\n</code></pre>\nScaffold a new project:<p><pre><code>  bun create crust my-cli\n</code></pre>\nSite: <a href=\"https:&#x2F;&#x2F;crustjs.com\" rel=\"nofollow\">https:&#x2F;&#x2F;crustjs.com</a>\nGitHub: <a href=\"https:&#x2F;&#x2F;github.com&#x2F;chenxin-yan&#x2F;crust\" rel=\"nofollow\">https:&#x2F;&#x2F;github.com&#x2F;chenxin-yan&#x2F;crust</a><p>Happy to answer any questions about the design decisions or internals.","time":1773722609,"title":"Show HN: Crust – A CLI framework for TypeScript and Bun","type":"story","url":"https://github.com/chenxin-yan/crust"}