2.0.11 • Published 6 years ago

sergent v2.0.11

Weekly downloads
2
License
MIT
Repository
github
Last release
6 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,
}
2.0.11

6 years ago

2.0.10

6 years ago

2.0.9

6 years ago

2.0.8

6 years ago

2.0.7

6 years ago

2.0.6

6 years ago

2.0.5

6 years ago

2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

0.1.0

6 years ago