@mtranter/clits
TypeScript icon, indicating that this package has built-in type declarations

0.1.15 • Public • Published

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"

Readme

Keywords

none

Package Sidebar

Install

npm i @mtranter/clits

Weekly Downloads

787

Version

0.1.15

License

MIT

Unpacked Size

324 kB

Total Files

19

Last publish

Collaborators

  • mtranter