Socket
Socket
Sign inDemoInstall

typed-cli

Package Overview
Dependencies
11
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    typed-cli

[![Coverage Status](https://coveralls.io/repos/github/int0h/typed-cli/badge.svg?branch=master)](https://coveralls.io/github/int0h/typed-cli?branch=master)


Version published
Weekly downloads
121
decreased by-13.57%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

typed-cli

Coverage Status

typed-cli logo

A library to help you create type-safe CLI's fast and simple.

Project state

This project is still alive and maintained. But it is not in active development.

Usage example

import {cli, option} from 'typed-cli';
import app from './app';

const {options} = cli({
    options: {
        env: option.oneOf(['dev', 'prod'] as const)
            .alias('e')
            .required()
            .description('app environment'),
        port: option.int
            .alias('p')
            .default(80)
            .description('port'),
    }
});

// port: number
// env: 'dev' | 'prod'
const {port, env} = options;


const DB_HOSTS = {
    dev: 'localhost:1234',
    prod: '1.2.3.4:9999',
} as const;

// Type safe!
// no "No index signature with a parameter of type 'string'" kind of errors
// because typeof env is 'dev' | 'prod'
app.run({
    db: DB_HOSTS[env],
    port
});

This code will behave like this:

terminal-demo

Playground

You can test it without installing anything on your machine. Just go to the

Interactive Demo

(⚠️it's about 20Mb of traffic). It has interactive terminal and code editor, you can change the samples and see how it reacts.

Key features

  • Type safety
  • input validation (customizable)
  • help generation
  • printing reports for invalid data
  • tab completions
  • input data transformation
  • support for commands

Documentation

The docs can be found here: https://int0h.github.io/typed-cli-docs/

Keywords

FAQs

Last updated on 03 Dec 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc