1.5.20 • Published 12 months ago

@ideascol/cli-maker v1.5.20

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

@ideascol/cli-maker

A library to help create CLIs with support for command parameters and interactive prompts.

Quick start

npx @ideascol/cli-maker

Installation

To install the library, use npm:

npm install -g @ideascol/cli-maker

Create your own CLI

cli-maker

Usage

To use the library, import the CliMaker class and create a new instance of it. Then, you can add commands and prompts to the CLI.

const { CLI, ParamType } = require('@ideascol/cli-maker');

const cli = new CLI("mycli", "A simple CLI", {
  interactive: true,
  version: '0.0.1',
});

let commandExample = {
  name: 'all-params',
  description: 'Show all params',
  params: [
    {
      name: 'favorite_fruit',
      description: 'select your favorite fruit',
      required: true,
      type: ParamType.List,
      options: ['manzana', 'pera', 'uva']
    },
    {
      name: 'url',
      description: 'The URL of your website',
      type: ParamType.Url,
      required: true
    },
    {
      name: "is_ok",
      description: "Is the user ok? (true or false)",
      type: ParamType.Boolean,
    },
    {
      name: 'email',
      description: 'The email',
      type: ParamType.Email,
      required: true
    },
    {
      name: 'age',
      description: 'The age of the user',
      type: ParamType.Number,
    },
    {
      name: 'metadata',
      description: 'List of tags',
      type: ParamType.List,
      options: ["tag1", "tag2"],
    },
    {
      name: 'tags',
      description: '(["tag1", "tag2"] or {"key1": "value1", "key2": "value2"})',
      type: ParamType.Custom,
      required: false,
    }
  ],
  action: (args) => {
    console.log('EXAMPLE DATA');
    console.log(args);
  }
}

cli.command(commandExample);

cli.parse(process.argv);
1.5.20

12 months ago

1.5.19

12 months ago

1.5.18

12 months ago

1.5.17

12 months ago

1.5.16

12 months ago

1.5.15

12 months ago

1.5.14

12 months ago

1.5.13

12 months ago

1.5.12

12 months ago

1.5.11

12 months ago

1.5.10

12 months ago

1.5.9

12 months ago

1.5.8

12 months ago

1.5.7

12 months ago

1.5.5

12 months ago

1.5.4

12 months ago

1.5.3

12 months ago

1.5.2

12 months ago

1.5.1

12 months ago

1.5.0

12 months ago

1.4.18

12 months ago

1.4.17

12 months ago

1.4.16

12 months ago

1.4.15

12 months ago

1.4.14

12 months ago

1.4.13

12 months ago

1.4.12

12 months ago

1.4.11

12 months ago

1.4.10

12 months ago

1.4.9

12 months ago

1.4.8

12 months ago

1.4.7

12 months ago

1.4.6

12 months ago

1.4.5

12 months ago

1.4.4

12 months ago

1.4.3

12 months ago

1.4.2

12 months ago

1.4.1

12 months ago

1.4.0

12 months ago

1.3.0

12 months ago

1.2.0

12 months ago

1.1.7

12 months ago

1.1.6

12 months ago

1.1.5

12 months ago

1.1.4

12 months ago

1.1.3

12 months ago

1.1.2

12 months ago

1.1.1

12 months ago

1.1.0

12 months ago

1.0.0

12 months ago