@cirrusct/cli
Command Line Interface
Last updated 2 months ago by cirrusct .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install @cirrusct/cli 
SYNC missed versions from official npm registry.

cli

npm version

Feature-rich, data-driven Node JS Command Line Interface (CLI) tool.

Installation

$ yarn add @cirrusct/cli
or
$ npm install @cirrusct/cli

Usage

import { Cli, CliProgramDefinition, CliRunResult } from '@cirrusct/cli';

// Define command(s)
const command: CliCommandDefinition = {
    // command name
    name: 'serve',
    description: 'Start Web Server',
    // handler called when command is executed 
    handler: parsed => {
        console.log(`Running command: ${parsed.parsedCommandName}`)
    },
    // define positional arguments
    arguments: [
        {
            name: 'arg1',
            description: 'First positional argument'
        }
    ],
    // define options (specified with '--[name]' or '-[flag]')
    options: [
        {
            name: 'logLevel',
            flag: 'l',
            description: 'Output message log level',
        },
    ],
};

// Define program containing array of commands
const cliProgram: CliProgramDefinition = {
    commands: [command],
    description: 'Server',
    name: 'server',
};

// Start Cli to parse command line and call command handler based on Cli input
export const start = async (): Promise<CliRunResult> => {
    return Cli.start(cliProgram)
};

API

Command Definition

The CliCommandDefinition interface defines a command to be parsed from CLI input and has the following properties:

Property Type Description
name string Command Name
description string Command description
arguments Array (CliCommandDefinitionArgument) Command Arguments
options Array (CliCommandDefinitionOption) Command Options
allowDynamicOptions (Optional) Boolean Allow options to be specified on command line that are not defined as part of the definition
examples string array Usage Examples
transformOptions (options) => Options Function to transform options
handler CommandHandler Function called when command is executed
env (Optional) Hash Environment
transformArguments (arguments) => Arguments Function to transform arguments

Current Tags

  • 1.1.65                                ...           latest (2 months ago)

89 Versions

  • 1.1.65                                ...           2 months ago
  • 1.1.64                                ...           2 months ago
  • 1.1.63                                ...           2 months ago
  • 1.1.62                                ...           2 months ago
  • 1.1.61                                ...           2 months ago
  • 1.1.60                                ...           2 months ago
  • 1.1.59                                ...           2 months ago
  • 1.1.58                                ...           4 months ago
  • 1.1.57                                ...           4 months ago
  • 1.1.56                                ...           7 months ago
  • 1.1.55                                ...           7 months ago
  • 1.1.54                                ...           7 months ago
  • 1.1.53                                ...           7 months ago
  • 1.1.52                                ...           7 months ago
  • 1.1.49                                ...           7 months ago
  • 1.1.48                                ...           7 months ago
  • 1.1.47                                ...           8 months ago
  • 1.1.46                                ...           8 months ago
  • 1.1.45                                ...           8 months ago
  • 1.1.44                                ...           8 months ago
  • 1.1.43                                ...           8 months ago
  • 1.1.42                                ...           8 months ago
  • 1.1.40                                ...           8 months ago
  • 1.1.39                                ...           8 months ago
  • 1.1.38                                ...           a year ago
  • 1.1.37                                ...           a year ago
  • 1.1.36                                ...           a year ago
  • 1.1.35                                ...           a year ago
  • 1.1.34                                ...           a year ago
  • 1.1.33                                ...           a year ago
  • 1.1.32                                ...           a year ago
  • 1.1.31                                ...           a year ago
  • 1.1.30                                ...           a year ago
  • 1.1.29                                ...           a year ago
  • 1.1.28                                ...           a year ago
  • 1.1.27                                ...           a year ago
  • 1.1.26                                ...           a year ago
  • 1.1.25                                ...           a year ago
  • 1.1.24                                ...           a year ago
  • 1.1.23                                ...           a year ago
  • 1.1.22                                ...           a year ago
  • 1.1.21                                ...           a year ago
  • 1.1.20                                ...           a year ago
  • 1.1.19                                ...           a year ago
  • 1.1.18                                ...           a year ago
  • 1.1.17                                ...           a year ago
  • 1.1.16                                ...           a year ago
  • 1.1.15                                ...           a year ago
  • 1.1.14                                ...           a year ago
  • 1.1.13                                ...           a year ago
  • 1.1.12                                ...           a year ago
  • 1.1.10                                ...           a year ago
  • 1.1.8                                ...           a year ago
  • 1.1.7                                ...           a year ago
  • 1.1.6                                ...           a year ago
  • 1.1.5                                ...           a year ago
  • 1.1.4                                ...           a year ago
  • 1.1.3                                ...           a year ago
  • 1.1.2                                ...           a year ago
  • 1.1.1                                ...           a year ago
  • 1.0.33                                ...           a year ago
  • 1.0.32                                ...           a year ago
  • 1.0.30                                ...           a year ago
  • 1.0.28                                ...           2 years ago
  • 1.0.27                                ...           2 years ago
  • 1.0.26                                ...           2 years ago
  • 1.0.25                                ...           2 years ago
  • 1.0.24                                ...           2 years ago
  • 1.0.23                                ...           2 years ago
  • 1.0.22                                ...           2 years ago
  • 1.0.21                                ...           2 years ago
  • 1.0.20                                ...           2 years ago
  • 1.0.19                                ...           2 years ago
  • 1.0.18                                ...           2 years ago
  • 1.0.17                                ...           2 years ago
  • 1.0.16                                ...           2 years ago
  • 1.0.15                                ...           2 years ago
  • 1.0.14                                ...           2 years ago
  • 1.0.13                                ...           2 years ago
  • 1.0.12                                ...           2 years ago
  • 1.0.11                                ...           2 years ago
  • 1.0.10                                ...           2 years ago
  • 1.0.9                                ...           2 years ago
  • 1.0.8                                ...           2 years ago
  • 1.0.7                                ...           2 years ago
  • 1.0.6                                ...           2 years ago
  • 1.0.5                                ...           2 years ago
  • 1.0.4                                ...           2 years ago
  • 1.0.3                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 90
Last Day 0
Last Week 90
Last Month 1
Dependencies (9)
Dev Dependencies (0)
None

Copyright 2014 - 2017 © taobao.org |