0.3.2 • Published 5 years ago

amiral v0.3.2

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

Amiral

Command line tool

Installation

npm i -S amiral

Dependencies

Usage

// my_module/bin/index.js
'use strict';

const Amiral = require('amiral');
const program = require('commander');
const path = require('path');
const { version } = require(path.resolve(__dirname, '..', 'package.json'));

const child_process = require('child_process');

Amiral.create({
    name: 'cowsay',
    description: 'Cow say some text',
    fields: [{
        name: 'content',
        label: 'What say the cow',
        required: false,
        argument: true,
    }, {
        name: 'file',
        label: 'What kind of cow',
        required: false,
        default: 'tux',
    }],
}).then((props) => {
    return child_process.spawn('cowsay', ['-f', props.file, props.content], { stdio: 'inherit' });
});

program.version(version, '-v, --version').parse(process.argv);

Schema

Command
const CommandSchema = {
    name: String,               // Command name used to be called in cli
    description: String,        // Command description used in help message
    help: String,               // Help message showing after command usage and options
    master: Boolean,            // Specify if command is the master command
    fields: [Field],            // Property that can be passed to command or prompted
}
Field
const FieldSchema = {
    label: String,              // Label used in question and field description
    name: String,               // Name of the field
    type: undefined,            // Specify the field type (Boolean, Number, String, Object, Array, Map)
    required: Boolean,          // Specify if the field is required
    default: undefined,         // Default value
    value: undefined,           // Stored value (filled automatically)
    children: [Fractale.SELF],  // Children 

    // Command specific
    shortcut: String,           // Command shortcut
    argument: Boolean,          // Specify if field is command argument

    // Question specific
    question: String,           // Inquirer question type
    message: String,            // Override label for question
    pageSize: Number,
    prefix: String,
    suffix: String,
    choices: undefined,
    filter: undefined,
    transformer: undefined,
    validate: undefined,
    when: undefined,
}
0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.9

5 years ago

0.2.8

5 years ago

0.2.7

5 years ago

0.2.6

5 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago