vipvot

Zero-dependency TypeScript port of cobra

Language
TypeScript
Version
0.4.0
License
MIT
Category
Ecosystem

A Bun-native CLI framework that mirrors Go's cobra/pflag exactly — command groups, flag-group constraints, persistent flags, the five-stage hook chain, and 33 pflag flag types. Differential-tested against a real cobra binary so a CLI written in vipvot translates back to Go cobra by mechanical rewrite. Powers the TypeScript agent-* CLIs in this collection.

Features

01

Cobra parity — command tree, persistent flags, flag-group constraints, five-stage hook chain

02

33 pflag flag types — scalars, slices (incl. IPSlice, IPNetSlice, UintSlice), maps, IP/CIDR, hex/base64, durations

03

POSIX/GNU parser — short combining (-vvv, -xVALUE), --no-foo negation, -- terminator

04

Differential-tested byte-for-byte against the cobra/pflag oracle

05

Doc generators — markdown, YAML, reST, man pages (vipvot/doc subpath)

06

Shell completion — bash, zsh, fish, PowerShell with dynamic value completers

07

Zero runtime dependencies — ~30 KB minified, ~8.5 KB gzipped

08

Bun-native build for `bun build --compile` single-binary CLIs; published ESM runs on Node 20+ too

Install

Bun

>_
$ bun add vipvot

npm

>_
$ npm install vipvot

Build from Source

>_
$ git clone https://github.com/shhac/vipvot.git && cd vipvot && bun install && bun run build

Usage

>_ Define a root command with flags
$ Command({ use: 'app', short: '...', run: (cmd, args) => {...} })
>_ Add a persistent flag inherited by subcommands
$ cmd.persistentFlags().stringP('config', 'c', '', 'config file')
>_ Mark flags mutually exclusive
$ cmd.markFlagsMutuallyExclusive('json', 'yaml')
>_ Generate markdown docs for the whole command tree
$ import { genMarkdownTree } from 'vipvot/doc'; genMarkdownTree(rootCmd, './docs')
>_ Generate zsh completion
$ import { genZshCompletion } from 'vipvot/completion'; genZshCompletion(rootCmd, process.stdout)