CLITS
Command Line Interface app builder for TypeScript.
Get your mind out of the gutter.
Strong typing for your CLI apps.
Validation using class-validator and class-transformer
Usage
index.ts
#!/usr/bin/env node
import { CliApp } from 'clits'
import { Type } from 'class-transformer';
import { IsCreditCard } from 'class-validator'
import { MySideProject } from './side-project'
const myRetirement = new MySideProject();
class CardDetails {
@Argument({
alias: "c",
required: true,
description: "Your card number"
})
@IsCreditCard()
public cardNumber: string
@Argument({
alias: "n",
required: true,
description: "The name on your card"
})
public cardName: string
@Argument({
alias: "e",
required: true,
description: "Card expiry"
})
@Type(() => Date)
public expiry: Date
}
const makeMoney = new CliApp("My CLI App")
.command("get-paid", CardDetails)
.handle(cardDeets => myRetirement.takePayment(cardDeets))
.run()
Then...
$> tsc
$> chmod +x ./dist/index.js
$> ./dist/index.js get-paid \
--cardNumber 1234-5678-1234-1111 \
--cardName "John Smith" \
-e "2025-01-01"