Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

181 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

maltty

An opinionated CLI framework for Node.js. Convention over configuration, end-to-end type safety.

CI npm version License

📖 Documentation    ·    🐛 Issues

Features

  • 🧰 Batteries included — Config, auth, prompts, logging, output, and middleware built in
  • 📁 File-system auto-loading — Drop a file in commands/, get a command
  • Build and compile — Bundle your command tree or produce cross-platform standalone binaries
  • 🚀 Two files to a full CLI — Define a schema, write a handler, done
  • 🛠️ Developer experience — Scaffolding, hot reload, route inspection, and diagnostics out of the box

Install

npm install maltty

Usage

Define your CLI

// index.ts
import { cli } from 'maltty'
import { z } from 'zod'

await cli({
  name: 'deploy',
  version: '0.1.0',
  config: {
    schema: z.object({
      registry: z.string().url(),
      region: z.enum(['us-east-1', 'eu-west-1']),
    }),
  },
})

Add a command

// commands/deploy.ts
import { command } from 'maltty'
import { z } from 'zod'

export default command({
  description: 'Deploy to the configured registry',
  args: z.object({
    tag: z.string().describe('Image tag to deploy'),
    dry: z.boolean().default(false).describe('Dry run'),
  }),
  handler: async (ctx) => {
    ctx.log.info(`Deploying ${ctx.args.tag} to ${ctx.config.region}`)
  },
})

Add a screen

// commands/dashboard.tsx
import { screen, Box, Text, useScreenContext } from 'maltty/ui'
import { z } from 'zod'

function Dashboard({ env }: { env: string }) {
  const ctx = useScreenContext()
  return (
    <Box flexDirection="column">
      <Text bold>Dashboard — {env}</Text>
      <Text>Region: {ctx.config.region}</Text>
    </Box>
  )
}

export default screen({
  description: 'Launch an interactive dashboard',
  options: z.object({
    env: z.string().default('staging').describe('Target environment'),
  }),
  render: Dashboard,
})

Run it

maltty dev -- deploy --tag v1.2.3         # dev mode
maltty build                              # bundle
maltty compile                            # standalone binary

License

MIT

About

Full-featured CLI framework for Node.js. Prebuilt components and Storybook for the terminal.

Resources

Contributing

Stars

3 stars

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages