1.7.0 • Published 9 months ago

@ideascol/cli-maker v1.7.0

Weekly downloads
-
License
MIT
Repository
-
Last release
9 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.6.3

10 months ago

1.6.2

10 months ago

1.6.1

11 months ago

1.6.0

11 months ago

1.7.0

9 months ago

1.5.20

2 years ago

1.5.19

2 years ago

1.5.18

2 years ago

1.5.17

2 years ago

1.5.16

2 years ago

1.5.15

2 years ago

1.5.14

2 years ago

1.5.13

2 years ago

1.5.12

2 years ago

1.5.11

2 years ago

1.5.10

2 years ago

1.5.9

2 years ago

1.5.8

2 years ago

1.5.7

2 years ago

1.5.5

2 years ago

1.5.4

2 years ago

1.5.3

2 years ago

1.5.2

2 years ago

1.5.1

2 years ago

1.5.0

2 years ago

1.4.18

2 years ago

1.4.17

2 years ago

1.4.16

2 years ago

1.4.15

2 years ago

1.4.14

2 years ago

1.4.13

2 years ago

1.4.12

2 years ago

1.4.11

2 years ago

1.4.10

2 years ago

1.4.9

2 years ago

1.4.8

2 years ago

1.4.7

2 years ago

1.4.6

2 years ago

1.4.5

2 years ago

1.4.4

2 years ago

1.4.3

2 years ago

1.4.2

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.0

2 years ago

1.2.0

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago