2.1.21 • Published 3 months ago

@gruzf/numen-cli v2.1.21

Weekly downloads
-
License
MIT
Repository
-
Last release
3 months ago

numen CLI

numen cli

Version Version Downloads Company

NUMEN CLI will help you easily and simply create your own cli library using typescript. Based on the @gruzf/numen

Install

npm install @gruzf/numen-cli

or

yarn add @gruzf/numen-cli

Usage

First of all, prepare your project structure

.
├── commands
│   ├── commandName1.ts
│   ├── commandName2.ts
│   ├── commandName3.ts
│   └── ...
└── index.ts

./index.ts

#!/usr/bin/env node

import { cli } from "@gruzf/numen-cli";

cli(options);

Options

checkVersion

Show a message about an available new version

  • Type: boolean
  • Default: false

./commands/commandName1.ts

import Command from "@gruzf/numen-cli/command";

export default class CommandName1 extends Command {
  description = "My first command";

  args = [{ name: "name", required: true }];

  options = [{ flag: "-l, --lastName <lastName>" }];

  run(name: string, { lastName }?: { lastName: string }): void {
    console.log(`Hello ${name}!`);

    return;
  }
}

Options

description
  • Type: string
  • Default: undefined
args
  • Type: [{ name: string; description: string; required: boolean }]
  • Default: undefined
options
  • Type: [{ flag: string; description: string; defaultValue: string | boolean; choices?: string[] }]
  • Default: undefined
isDefault
  • Type: boolean
  • Default: false

Don't forget about the bin property in the package.json file. When you publish your library you will be able to call it via myLib

{
  "name": "my-lib",
  "version": "1.0.0",
  "main": "./index.js",
  "bin": {
    "myLib": "./index.js"
  }
}

Compiling

Compile your code with numen

numen watch

Run node lib

After publishing just myLib

node lib

Usage: mylib [options] [command]

Options:
  -v, --version        output the version number
  -h, --help           display help for command

Commands:
  commandName1 <name>  My first command
  help [command]       display help for command
node lib commandName1 World

Hello World!
2.1.21

3 months ago

2.1.20

3 months ago

2.1.19

10 months ago

2.1.18

12 months ago

2.1.9

1 year ago

2.1.16

1 year ago

2.1.17

1 year ago

2.1.14

1 year ago

2.1.15

1 year ago

2.1.12

1 year ago

2.1.13

1 year ago

2.1.10

1 year ago

2.1.11

1 year ago

2.1.6

1 year ago

2.1.5

1 year ago

2.1.8

1 year ago

2.1.7

1 year ago

2.1.2

1 year ago

2.0.3

1 year ago

2.1.1

1 year ago

2.0.2

1 year ago

2.1.4

1 year ago

2.1.3

1 year ago

2.0.4

1 year ago

2.1.0

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.1.12

2 years ago

1.1.11

2 years ago

1.1.13

2 years ago

1.1.9

2 years ago

1.1.10

2 years ago

1.1.8

2 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago